2017-08-30 53 views
2

我在這裏搜索了很多,但不幸找不到答案。獲取ML-Engine預測的錯誤,但本地預測工作正常

我我的本地機器上運行TensorFlow 1.3(通過畫中畫安裝在MacOS),並使用providedssd_mobilenet_v1_coco」闖關已經創建了一個模型。

我設法在本地和ML-Engine(Runtime 1.2)上進行培訓,併成功地將我的savedModel部署到ML-Engine。

本地預測(下面的代碼)正常工作,我得到部署模型,並試圖在ML-ENGINE與下面的代碼遠程預測運行時模型結果

gcloud ml-engine local predict --model-dir=... --json-instances=request.json 

FILE request.json: {"inputs": [[[242, 240, 239], [242, 240, 239], [242, 240, 239], [242, 240, 239], [242, 240, 23]]]} 

但是:

gcloud ml-engine predict --model "testModel" --json-instances request.json(SAME JSON FILE AS BEFORE) 

我得到這個錯誤:

{ 
    "error": "Prediction failed: Exception during model execution: AbortionError(code=StatusCode.INVALID_ARGUMENT, details=\"NodeDef mentions attr 'data_format' not in Op<name=DepthwiseConv2dNative; signature=input:T, filter:T -> output:T; attr=T:type,allowed=[DT_FLOAT, DT_DOUBLE]; attr=strides:list(int); attr=padding:string,allowed=[\"SAME\", \"VALID\"]>; NodeDef: FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_1_depthwise/depthwise = DepthwiseConv2dNative[T=DT_FLOAT, _output_shapes=[[-1,150,150,32]], data_format=\"NHWC\", padding=\"SAME\", strides=[1, 1, 1, 1], _device=\"/job:localhost/replica:0/task:0/cpu:0\"](FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_0/Relu6, FeatureExtractor/MobilenetV1/Conv2d_1_depthwise/depthwise_weights/read)\n\t [[Node: FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_1_depthwise/depthwise = DepthwiseConv2dNative[T=DT_FLOAT, _output_shapes=[[-1,150,150,32]], data_format=\"NHWC\", padding=\"SAME\", strides=[1, 1, 1, 1], _device=\"/job:localhost/replica:0/task:0/cpu:0\"](FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_0/Relu6, FeatureExtractor/MobilenetV1/Conv2d_1_depthwise/depthwise_weights/read)]]\")" 
} 

我看到了類似的東西在這裏: https://github.com/tensorflow/models/issues/1581

關於「數據格式」參數的問題。 但不幸的是我無法使用該解決方案,因爲我已經在TensorFlow 1.3上。

它也似乎,這可能是與MobilenetV1一個問題:https://開頭github.com/ tensorflow /模型/問題/ 2153

任何想法?

+0

你怎麼在本地,併成功培養部署了savedModel到ML-引擎?這似乎意味着您使用TensorFlow 1.3進行訓練,然後使用版本1.2進行預測。 – George

+0

嗨,喬治!感謝您的評論! 我確實使用過TF1.3進行訓練,也許情況就是這樣。但是,我怎樣才能使用1.2進行預測呢?我可以在gcloud工具或網頁界面上設置? –

+0

您可以在本地使用版本1.2的TF來進行模型培訓,代替當前的TF1.3。 – George

回答

3

我有一個類似的issue。此問題是由於用於訓練和推理的Tensorflow版本不匹配造成的。我通過使用Tensorflow-1.4來解決這個問題,用於訓練和推理。

請參閱this的答案。

+0

非常感謝!對於我正在研究的項目,我們決定不使用GCP-ML,因爲這個,但我一定會檢查它 因爲我相信你的答案應該解決這個問題,我會標記爲已解決,我很高興TF團隊這樣做= D –

1

如果你想知道如何確保你的模型版本正在運行,你需要運行正確tensorflow版本,先看看這個model versions list page

你需要知道哪個模型版本支持Tensorflow版本你需要的。在寫這篇文章的時間:

  • ML版本1.4支持TensorFlow 1.4.0和1.4.1
  • ML版本1.2支持TensorFlow 1.2.0和
  • ML版本1.0支持TensorFlow 1.0.1

現在你知道哪個模型,你需要的版本,你需要從你的模型創建一個新的版本,像這樣:

gcloud ml-engine versions create <version name> \ 
--model=<Name of the model> \ 
--origin=<Model bucket link. It starts with gs://...> \ 
--runtime-version=1.4 

在我的情況下,我需要預測使用Tensorflow 1.4.1,所以我使用了運行時版本1.4。

請參閱本official MNIST tutorial page,以及本ML Versioning Page