簡體   English   中英

在Google Cloud ml引擎上調用本地預測或創建模型版本時,Scikit Learn模型導致錯誤

[英]Scikit Learn model results in error when calling local predict or creating model version on Google Cloud ml engine

我正在嘗試按照此處的教程( https://cloud.google.com/ml-engine/docs/scikit/quickstart )將模型部署到cloud-ml引擎,但是當我到達階段時, m使用以下命令運行在線預測:

gcloud ml-engine local predict --model-dir=$MODEL_DIR --json-instances 
 $INPUT_FILE --framework $FRAMEWORK

它導致此錯誤:

ERROR: (gcloud.ml-engine.local.predict) RuntimeError: Bad magic number in .pyc file

此外,當嘗試使用此命令創建模型版本時:

gcloud ml-engine versions create $VERSION_NAME --model $MODEL_NAME --origin 
$MODEL_DIR --runtime-version=1.12 --framework $FRAMEWORK --python-version=3.5

它導致此錯誤:

ERROR: (gcloud.ml-engine.versions.create) Bad model detected with error: "Failed to load model: Could not load the model: /tmp/model/0001/model.joblib. 162. (Error code: 0)"

這里發生了什么? 我正在運行Python 3.5.2。

我需要更多有關您在預測請求中傳遞給Cloud ml引擎的信息,特別是它包含兩個參數:

name=name, body={'instances': instances_array}

我經常看到的一個錯誤是將實例主體參數作為JSON而不是數組傳遞。 這是使用一些數字(浮點)變量的示例:

"instances": [
[0.46453494969873,0.96359384261176,-1.30875379350541,0.143317957209722,-1.05224729148452,0.145418363035172,1.23393185625915,1.88694142308998,0.0739610367506085,0.00900364697319474],
[2.66970600786085,0.671393792256777,0.999557100651135,0.470837952361579,-0.392487317572142,-0.758011630059567,1.56168018313734,0.363605558678856,-1.41676037696331,-0.933208457148377],]

希望這可以幫助

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM