TensorFlow:如何为 SavedModel 格式化 JSON,期望字符串格式为 3 个整数?
TensorFlow: How to format JSON for SavedModel expecting 3 ints in string format?
我在使用 Postman 在 Docker 容器中使用 TensorFlow Serving 向我的模型 运行 发送正确的预测 POST 请求时遇到问题。
该模型响应 GET 请求,因此我知道它有效并且正在响应。该算法需要将 3 个 int ID 值作为类别处理才能运行,但 SignatureDef 需要输入一个字符串,如下所示:
The given SavedModel SignatureDef contains the following input(s):
inputs['inputs'] tensor_info:
dtype: DT_STRING
shape: (-1)
name: input_example_tensor:0
The given SavedModel SignatureDef contains the following output(s):
outputs['classes'] tensor_info:
dtype: DT_STRING
shape: (-1, 2166)
name: linear/head/Tile:0
outputs['scores'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 2166)
name: linear/head/predictions/probabilities:0
Method name is: tensorflow/serving/classify
我已尝试按照 RESTful API 教程中显示的 JSON 格式设置:https://www.tensorflow.org/tfx/serving/api_rest#example
但是除了错误响应之外什么都不能给我发回,这些错误响应对我了解正确的语法没有多大帮助。无论如何,它需要是这样的:
{
"inputs": ['int1': 1, 'int2': 2, 'int3': 3]
}
我期待它给我发回教程中所示的内容:
"predictions": [3.5, 4.0, 5.5]
相反,我收到了 "error":无论我这次发送的内容有什么不满意之处。任何帮助将不胜感激
在咨询了其他几个人之后,我们设法找到了解决方案。它需要一个字符串列表,每个字符串都包含相关的字典项,在标签需要的地方转义引号。
{
"instances":
["\"int1\": [1] , \"int2\" : [2], \"int3\":[3]"]
}
我在使用 Postman 在 Docker 容器中使用 TensorFlow Serving 向我的模型 运行 发送正确的预测 POST 请求时遇到问题。
该模型响应 GET 请求,因此我知道它有效并且正在响应。该算法需要将 3 个 int ID 值作为类别处理才能运行,但 SignatureDef 需要输入一个字符串,如下所示:
The given SavedModel SignatureDef contains the following input(s):
inputs['inputs'] tensor_info:
dtype: DT_STRING
shape: (-1)
name: input_example_tensor:0
The given SavedModel SignatureDef contains the following output(s):
outputs['classes'] tensor_info:
dtype: DT_STRING
shape: (-1, 2166)
name: linear/head/Tile:0
outputs['scores'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 2166)
name: linear/head/predictions/probabilities:0
Method name is: tensorflow/serving/classify
我已尝试按照 RESTful API 教程中显示的 JSON 格式设置:https://www.tensorflow.org/tfx/serving/api_rest#example 但是除了错误响应之外什么都不能给我发回,这些错误响应对我了解正确的语法没有多大帮助。无论如何,它需要是这样的:
{
"inputs": ['int1': 1, 'int2': 2, 'int3': 3]
}
我期待它给我发回教程中所示的内容:
"predictions": [3.5, 4.0, 5.5]
相反,我收到了 "error":无论我这次发送的内容有什么不满意之处。任何帮助将不胜感激
在咨询了其他几个人之后,我们设法找到了解决方案。它需要一个字符串列表,每个字符串都包含相关的字典项,在标签需要的地方转义引号。
{
"instances":
["\"int1\": [1] , \"int2\" : [2], \"int3\":[3]"]
}