Windows 10和Docker tensorflow / serving。在构造JSON来请求预测时遇到问题,希望有人可以帮助我。
我尝试了不同格式的json,但都没有成功。
关于Tensorflow服务提供的模型的信息:
http://localhost:8501/v1/models/my_model/metadata:
{
"model_spec": {
"name": "my_model",
"signature_name": "",
"version": "1"
},
"metadata": {
"signature_def": {
"signature_def": {
"__saved_model_init_op": {
"inputs": {},
"outputs": {
"__saved_model_init_op": {
"dtype": "DT_INVALID",
"tensor_shape": {
"dim": [],
"unknown_rank": true
},
"name": "NoOp"
}
},
"method_name": ""
},
"serving_default": {
"inputs": {
"lstm_input": {
"dtype": "DT_FLOAT",
"tensor_shape": {
"dim": [
{
"size": "-1",
"name": ""
},
{
"size": "50",
"name": ""
},
{
"size": "5",
"name": ""
}
],
"unknown_rank": false
},
"name": "serving_default_lstm_input:0"
},
"tech_input": {
"dtype": "DT_FLOAT",
"tensor_shape": {
"dim": [
{
"size": "-1",
"name": ""
},
{
"size": "1",
"name": ""
}
],
"unknown_rank": false
},
"name": "serving_default_tech_input:0"
}
},
"outputs": {
"dense_out": {
"dtype": "DT_FLOAT",
"tensor_shape": {
"dim": [
{
"size": "-1",
"name": ""
},
{
"size": "1",
"name": ""
}
],
"unknown_rank": false
},
"name": "StatefulPartitionedCall:0"
}
},
"method_name": "tensorflow/serving/predict"
}
}
}
}
}
发布请求后,我认为是正确的JSON主体(但不是):
{
"inputs":{
"lstm_input":[
[
0.178988,
0.172787,
0.182751,
0.177997,
0.138975
],
.. ommitted, 50 in total ..
[
0.248429,
0.244069,
0.248119,
0.245594,
0.404607
]
],
"tech_input":[
[
0.256009
]
]
}
}
我期望返回预测(浮动),但会收到错误消息:
{"error": "transpose expects a vector of size 2. But input(1) is a vector of size 3\n\t [[{{node model_3/lstm_0/transpose}}]]"}
我现在得到了预期的预测
这两个更改中的任何一个都可以解决问题,可能是第一个。
{
"inputs":{
"lstm_input":[
[
[
0.178988,
0.172787,
0.182751,
0.177997,
0.138975
],
.. ommitted, 50 in total ..
[
0.248429,
0.244069,
0.248119,
0.245594,
0.404607
]
]
],
"tech_input":[
[
0.256009
]
]
}
}
希望此信息也可能对其他人有所帮助