张量流ML-Engine在线预测所需的输出占位符

时间:2019-03-29 14:20:36

标签: python tensorflow machine-learning

了解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}}]]\")"
}

现在:

  1. 我不明白为什么它要我为OUTPUT提供价值
  2. 尝试使用这样的名称outputPlaceholder_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']."
}

0 个答案:

没有答案