了解TensorFlow以及如何请求GCP ML-Engine在线预测。
已经定义,训练,保存了模型并将其部署到GCP中。
模型输入/输出定义为:
$ saved_model_cli show --all --dir=./my-model
MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs:
signature_def['predict_spam']:
The given SavedModel SignatureDef contains the following input(s):
inputs['input'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 1701)
name: Placeholder:0
The given SavedModel SignatureDef contains the following output(s):
outputs['output'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 2)
name: Placeholder_1:0
Method name is: tensorflow/serving/predict
我正在使用gcloud命令:
gcloud ml-engine predict --model "SpamBinary" --version "v3" --json-instances "request.json"
并提供request.json
为:
{"input": [0.000000000000000000e+00,0.000000000000000000e+00, ... ,0.000000000000000000e+00]}
响应为:
{
"error": "Prediction failed: Error during model execution: AbortionError(code=StatusCode.INVALID_ARGUMENT, details=\"You must feed a value for placeholder tensor 'Placeholder_1' with dtype float and shape [?,2]\n\t [[{{node Placeholder_1}}]]\")"
}
现在:
output
或Placeholder_1
来提供这样的附加张量: {"input": [0.000000000000000000e+00,0.000000000000000000e+00, ... ,0.000000000000000000e+00], "output": [0.0, 1.0]}
原因错误:
{
"error": "Prediction failed: Expected tensor name: input, got tensor name: [u'input', u'output']."
}