通过CloudML获取TFrecord的批量预测
我遵循了这个很棒的教程,并成功地在CloudML上训练了一个模型。我的代码还离线进行预测,但是现在我正在尝试使用Cloud
ML进行预测并遇到一些问题。
为了部署我的模型,我遵循了本教程。现在,我有一个生成TFRecords
via的代码,apache_beam.io.WriteToTFRecord
并且我想对此进行预测TFRecords
。为此,我关注本文,我的命令如下所示:
gcloud ml-engine jobs submit prediction $JOB_ID --model $MODEL --input-paths gs://"$FILE_INPUT".gz --output-path gs://"$OUTPUT"/predictions --region us-west1 --data-format TF_RECORD_GZIP
但是我只有错误: 'Exception during running the graph: Expected serialized to be a
scalar, got shape: [64]
看起来它期望数据采用不同的格式。我在这里找到了JSON的格式规范,但找不到如何使用TFrecords进行格式化。
更新:这是输出 saved_model_cli show --all --dir
MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs:
signature_def['prediction']:
The given SavedModel SignatureDef contains the following input(s):
inputs['example_proto'] tensor_info:
dtype: DT_STRING
shape: unknown_rank
name: input:0
The given SavedModel SignatureDef contains the following output(s):
outputs['probability'] tensor_info:
dtype: DT_FLOAT
shape: (1, 1)
name: probability:0
Method name is: tensorflow/serving/predict
signature_def['serving_default']:
The given SavedModel SignatureDef contains the following input(s):
inputs['example_proto'] tensor_info:
dtype: DT_STRING
shape: unknown_rank
name: input:0
The given SavedModel SignatureDef contains the following output(s):
outputs['probability'] tensor_info:
dtype: DT_FLOAT
shape: (1, 1)
name: probability:0
Method name is: tensorflow/serving/predict