首页 > 解决方案 > 如何通过仅保存一份用户特征副本来减少 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文件更小,预测的延迟更少?

谢谢!

标签: tensorflow2.0tensorflow-servingtensorflow-transform

解决方案


推荐阅读