【发布时间】:2018-04-12 17:58:39
【问题描述】:
我已经构建并训练了一个 TensorFlow 模型,该模型使用 tf.Estimator 范式进行部署。我已经建立了一个如下所示的服务功能:
def serving_input_fn(params):
feature_placeholders = {
'inputs' : tf.placeholder(tf.int64, [None], name='inputs')
}
features = {
key: tensor
for key, tensor in feature_placeholders.items()
}
return tf.estimator.export.ServingInputReceiver(features, feature_placeholders)
现在,我希望能够使用 application/json 作为内容类型来调用它。所以我构建了一个 JSON 文件,就像我在 question 中找到的示例一样:
payload = {'instances': [{'inputs': [1039]}]}
json_string = json.dumps(payload)
当我调用模型时,我会返回:
ERROR in serving: Unsupported request data format: {u'instances': [{u'inputs': [1039]}]}.
Valid formats: tensor_pb2.TensorProto, dict<string, tensor_pb2.TensorProto> and predict_pb2.PredictRequest
有什么想法可以实现我的目标吗?
【问题讨论】:
标签: tensorflow tensorflow-serving