有没有人尝试过导出在本地机器上构建的 tensorflow 模型并使用谷歌云 ml 预测 API 上传这个模型?
我正在尝试在我的本地机器上使用此博客中给出的再训练示例的稍微修改版本来构建图形,并将导出的模型检查点直接上传到云 ml 进行预测。但是它抛出一个错误说:
ERROR: (gcloud.beta.ml.predict) HTTP request failed. Response: {
"error": {
"code": 503,
"message": "Field: name Error: Online prediction service is unavailable for this version. Please
try again in around 60 seconds.",
"status": "UNAVAILABLE",
"details": [
{
"@type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "name",
"description": "Online prediction service is unavailable for this version. Please try aga
in in around 60 seconds."
}
]
}
]
}
}
当进行调试时,我尝试使用相同的图形和相同的示例进行本地预测 command gcloud beta ml local predict
,它给出了错误:
ERROR: (gcloud.beta.ml.local.predict) WARNING:root:Couldn't find python-snappy so the implementation
of _TFRecordUtil._masked_crc32c is not as fast as it could be.
Traceback (most recent call last):
File "lib/googlecloudsdk/command_lib/ml/local_predict.py", line 112, in <module>
main()
File "lib/googlecloudsdk/command_lib/ml/local_predict.py", line 107, in main
instances=instances)
File "/root/.local/lib/python2.7/site-packages/google/cloud/ml/prediction/_prediction_lib.py", line
731, in local_predict
client = SessionClient(*load_model(model_dir))
File "/root/.local/lib/python2.7/site-packages/google/cloud/ml/prediction/_prediction_lib.py", line
339, in load_model
model_path)
File "/root/.local/lib/python2.7/site-packages/google/cloud/ml/session_bundle/_session_bundle.py",
line 153, in load_session_bundle_from_path
saver = tf.train.import_meta_graph(meta_graph_def)
File "/root/.local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1708, in
import_meta_graph
return _import_meta_graph_def(meta_graph_or_file, clear_devices)
File "/root/.local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1598, in
_import_meta_graph_def
input_graph_def, name="", producer_op_list=producer_op_list)
File "/root/.local/lib/python2.7/site-packages/tensorflow/python/framework/importer.py", line 258,
in import_graph_def
op_def = op_dict[node.op]
KeyError: u'TensorArrayV2'
似乎它无法从模型中导入所有图形元素。我已经使用这个命令导出了模型:
saver.export_meta_graph(filename=os.path.join("/trainer/", 'export.meta'))
saver.save(sess, os.path.join("/trainer/", 'export'), write_meta_graph=False)