首页 > 解决方案 > Google Cloud ML-Engine 在线预测错误:为已包含的占位符张量提供值

问题描述

我这几天一直面临以下错误,但仍然无法提出解决方案:

InvalidArgumentError(有关回溯,请参见上文):您必须为占位符张量“decoder_input”提供一个 dtype float 和 shape [?,?,1] 的值

[[节点decoder_input(定义在/Users/me/Downloads/google-cloud-sdk/lib/third_party/ml_sdk/cloud/ml/prediction/frameworks/tf_prediction_lib.py:210)]]

(错误代码:2)

我训练了我的tf.keras.Model(Python 3.6,Tensorflow 1.13.1)并将其成功导出到 Google Cloud ML-engine。

通过运行saved_model_cli show --all --dir=trainer/predict-dir/1552642125我得到:

MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs:

signature_def['serving_default']:
  The given SavedModel SignatureDef contains the following input(s):
    inputs['decoder_input'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1, -1, 1)
        name: decoder_input_1:0
    inputs['encoder_input'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1, -1, 1)
        name: encoder_input_1:0
  The given SavedModel SignatureDef contains the following output(s):
    outputs['reg_sequence_prediction'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1, -1, 1)
        name: reg_sequence_prediction/BiasAdd:0
  Method name is: tensorflow/serving/predict

我的instances.json文件是:

{"decoder_input": [[0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0]], "encoder_input": [[-1.1672], [-1.1672], [-1.1672], [-1.1672], [-1.1672], [-1.1672], [-1.1672], [-1.1672], [-1.1672], [-1.1672], [-1.1672], [-1.1672], [-1.1672], [-1.1672], [-1.1672], [-1.1672]]}

如您所见,我包含了两个必要的输入值,但我仍然收到相同的错误。

我没有包含任何 Dropout 或正则化层,该模型是一个简单的 seq2seq keras 模型,带有 RNN 和 GRUCells。

预先感谢您的帮助。

标签: pythontensorflowgoogle-cloud-platformtensorflow-servinggoogle-cloud-ml

解决方案


推荐阅读