简体   繁体   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

I'm trying to deploy a model to the cloud-ml engine by following the tutorial here ( https://cloud.google.com/ml-engine/docs/scikit/quickstart ), however when I reach the stage when I'm running the online prediction with this command: 我正在尝试按照此处的教程( 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

It results in this error: 它导致此错误:

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

Additionally, when trying to create a model version with this command: 此外,当尝试使用此命令创建模型版本时:

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

It results in this error: 它导致此错误:

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)"

What's going on here? 这里发生了什么? I'm running Python 3.5.2. 我正在运行Python 3.5.2。

I would need a bit more information regarding what you passing over to cloud ml engine in the predict request, in particular it takes in two params: 我需要更多有关您在预测请求中传递给Cloud ml引擎的信息,特别是它包含两个参数:

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

An error I often see is passing the instances body parameter as a JSON rather than as an array. 我经常看到的一个错误是将实例主体参数作为JSON而不是数组传递。 here is an example using a few numerical (float) variables: 这是使用一些数字(浮点)变量的示例:

"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],]

Hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google Cloud ML引擎scikit学习预测概率'predict_proba()' - Google Cloud ML-engine scikit-learn prediction probability 'predict_proba()' Google Cloud ML Engine:创建模型版本失败 - Google Cloud ML Engine: Create model version failed Cloud ML Engine和Scikit-Learn:'LatentDirichletAllocation'对象没有属性'predict' - Cloud ML Engine and Scikit-Learn: 'LatentDirichletAllocation' object has no attribute 'predict' 如何转换Scikit Learn OneVsRestClassifier预测方法输出到谷云ML的密集阵列? - How to convert Scikit Learn OneVsRestClassifier predict method output to dense array for google cloud ML? 使 ML model scikit-learn 兼容 - Making a ML model scikit-learn compatible 预测多个值作为scikit学习的模型结果 - Predict multiple values as model result in scikit learn 从Google Cloud ML-Engine的已部署SCIKITLEARN模型进行预测 - Prediction from a Deployed SCIKITLEARN model at Google Cloud ML-Engine 使用ML model (.pkl) 预测时出现DataException错误 - DataException error appears when using ML model (.pkl) to predict 在 AWS Sagemaker 中为 scikit 学习模型创建端点 - creating endpoint for scikit learn model in AWS Sagemaker scikit-learn - 预测新输入的训练模型 - scikit-learn - predict trained model on new input
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM