【发布时间】:2017-09-07 11:22:53
【问题描述】:
我正在尝试让 tensorflow boston 样本 (https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/tutorials/input_fn) 在 google cloudml 上运行,而且我似乎在训练中取得了成功,但我在随后的预测中遇到了困难。
我已经调整了代码以适应 tf.contrib.learn.Experiment 和 learn_runner.run()。它通过“gcloud ml-engine local train ...”/“gcloud ml-engine jobs submit training ...”在本地和云端运行。
我可以使用经过训练的模型运行 estimator.predict(input_fn=predict_input_fn)) 并使用给定的 boston_predict.csv 集获得有意义的预测。
我可以使用“gcloud ml-engine models create ...”和“gcloud ml-engine versions create ...”在云中创建模型并对其进行版本控制
但是
- 通过“gcloud ml-engine local predict --model-dir=/export/Servo/XXX --text-instances boston_predict.csv”的本地预测失败,并出现“InvalidArgumentError(请参见上文的回溯):无法解析示例输入 <..>(错误代码:2)。请参阅下面的成绩单。它与无标题 boston_predict.csv 类似地失败。
我已经使用“$ gcloud ml-engine local predict --help ",阅读https://cloud.google.com/ml-engine/docs/how-tos/troubleshooting,但通常无法通过谷歌或stackexhange 找到我的具体错误报告。
我是菜鸟,所以我可能在某些基本方面犯了错误,但我无法发现它。
感谢所有帮助,
:-)
yarc68000。
-------环境---------
(env1) $ gcloud --version
Google Cloud SDK 170.0.0
alpha 2017.03.24
beta 2017.03.24
bq 2.0.25
core 2017.09.01
datalab 20170818
gcloud
gsutil 4.27
(env1) $ python --version
Python 2.7.13 :: Anaconda 4.3.1 (64-bit)
(env1) $ conda list | grep tensorflow
tensorflow 1.3.0 <pip>
tensorflow-tensorboard 0.1.6 <pip>
------------执行和错误:boston_predict.csv ----------
$ gcloud ml-engine local predict --model-dir=<..>/export/Servo/1504780684 --text-instances 1709boston/boston_predict.csv
<..>
ERROR:root:Exception during running the graph: Could not parse example input, value: 'CRIM,ZN,INDUS,NOX,RM,AGE,DIS,TAX,PTRATIO'
[[Node: ParseExample/ParseExample = ParseExample[Ndense=9, Nsparse=0, Tdense=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], dense_shapes=[[1], [1], [1], [1], [1], [1], [1], [1], [1]], sparse_types=[], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_Placeholder_0_0, ParseExample/ParseExample/names, ParseExample/ParseExample/dense_keys_0, ParseExample/ParseExample/dense_keys_1, ParseExample/ParseExample/dense_keys_2, ParseExample/ParseExample/dense_keys_3, ParseExample/ParseExample/dense_keys_4, ParseExample/ParseExample/dense_keys_5, ParseExample/ParseExample/dense_keys_6, ParseExample/ParseExample/dense_keys_7, ParseExample/ParseExample/dense_keys_8, ParseExample/Const, ParseExample/Const_1, ParseExample/Const_2, ParseExample/Const_3, ParseExample/Const_4, ParseExample/Const_5, ParseExample/Const_6, ParseExample/Const_7, ParseExample/Const_8)]]
<..>
------- 执行和错误无标题 boston_predict.csv ------
(这里我尝试使用 boston_predict.csv 并省略第一行)
$ gcloud ml-engine local predict --model-dir=<..>/export/Servo/1504780684 --text-instances 1709boston/boston_predict_headerless.csv
<..>
ERROR:root:Exception during running the graph: Could not parse example input, value: '0.03359,75.0,2.95,0.428,7.024,15.8,5.4011,252,18.3'
[[Node: ParseExample/ParseExample = ParseExample[Ndense=9, Nsparse=0, Tdense=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], dense_shapes=[[1], [1], [1], [1], [1], [1], [1], [1], [1]], sparse_types=[], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_Placeholder_0_0, ParseExample/ParseExample/names, ParseExample/ParseExample/dense_keys_0, ParseExample/ParseExample/dense_keys_1, ParseExample/ParseExample/dense_keys_2, ParseExample/ParseExample/dense_keys_3, ParseExample/ParseExample/dense_keys_4, ParseExample/ParseExample/dense_keys_5, ParseExample/ParseExample/dense_keys_6, ParseExample/ParseExample/dense_keys_7, ParseExample/ParseExample/dense_keys_8, ParseExample/Const, ParseExample/Const_1, ParseExample/Const_2, ParseExample/Const_3, ParseExample/Const_4, ParseExample/Const_5, ParseExample/Const_6, ParseExample/Const_7, ParseExample/Const_8)]]
<..>
【问题讨论】:
-
您介意分享您的代码吗?
-
后续问题:你打算使用模型进行在线预测吗?如果是这样,我建议使用 JSON 作为输入。
标签: tensorflow gcloud google-cloud-ml-engine