tensorflow2.0 - 如何通过仅保存一份用户特征副本来减少 TensorFlow 服务的有效负载
问题描述
我有以下模型来预测用户对项目的偏好。模型将使用 Tensorflow 服务提供服务,输入将通过 json 有效负载文件发送到模型。
item_a_inputs = layers.Input(shape=(2,), name='a')
item_b_inputs = layers.Input(shape=(2,), name='b')
user_c_inputs = layers.Input(shape=(12000, ), name='c')
merged_layer = layers.concatenate([item_a_inputs, item_b_inputs, user_c_inputs], name='concatenate3')
predictions = layers.Dense(1, activation='sigmoid',
bias_initializer=None, name='sigmoid1')(merged_layer)
test_model = keras.Model(inputs=[item_a_inputs, item_b_inputs, user_c_inputs], outputs=predictions)
对于每一次,该模型将预测一个用户对 1000 个项目的偏好。现在我必须重复功能 user_c_inputs 1000 次并将所有重复项保存在 json 文件中。
是不是可以在json文件中只保存一份user_c_inputs,让json文件更小,预测的延迟更少?
谢谢!
解决方案
推荐阅读
- javascript - 在mongodb的控制器中访问集合,表达
- c++ - 获取内存地址而不是双精度值
- javascript - 如何处理 uid 在不同的地方被解释?
- php - 在 WooCommerce 中为结帐邮政编码字段设置 maxlength
- java - 如何在java中将输出小数格式化为小数点后两位?
- android - 通过代码关闭 Searchview (Android : androidx.appcompat.widget)
- python - 有没有办法在 askopenfile 对话框窗口中添加按钮?
- class - 时序图中的方法
- javascript - 粘性用户输入和按钮彼此相邻 css
- sql-server - 根据 MSSQL 中不同表中列的值在表中插入一行