简体   繁体   English

ml-engine-没有名为Trainer的模块

[英]ml-engine - no module named trainer

I have a directory of: 我有一个目录:

/ml_engine
  setup.py
  /trainer
    __init__.py
    task.py
    model.py

I have a custom model used with sklearn mixins that allows me to use the model as a sklearn model. 我有一个与sklearn mixins一起使用的自定义模型,该模型允许我将该模型用作sklearn模型。

However when I try to upload the model I would get the error: 但是,当我尝试上传模型时,会出现错误:

gcloud alpha ml-engine versions create m_0_03 \
--model model_9281830085_204245556_prophet \
--origin gs://BUCKET/9281830085_204245556/2018-08-23T13:37:00.000218 \
--runtime-version=1.9 \
--framework SCIKIT_LEARN \
--python-version=3.5 \
--package-uris=["gs://BUCKET/model_packages/trainer/"] \
--model-class=trainer.model \

Creating version (this might take a few minutes)......
...................................................................................................failed.
ERROR: (gcloud.alpha.ml-engine.versions.create) Bad model detected with error:  "Failed to load model: Could not load the model: /tmp/model/0001/model.pkl. No module named 'trainer'. (Error code: 0)"

Does ml-engine with alpha commands support this kind of operation? 带alpha命令的ml-engine是否支持这种操作?

您需要运行python setup.py --sdist ,然后将dist/trainer.tgz上传到GCS并将其用作--package-uris

I using sklearn_crfsuite estimator 我使用sklearn_crfsuite估算器

crf = sklearn_crfsuite.CRF(

    algorithm='lbfgs',
    c1=0.1,
    c2=0.1,
    max_iterations=2,
    all_possible_transitions=True
)

I'm saving the model as described below: 我将按照以下说明保存模型:

model = 'model.joblib'

joblib.dump(crf, model)

and when I try to deploy the model it reports this error: 当我尝试部署模型时,它报告此错误:

ERROR: (gcloud.alpha.ml-engine.versions.create) Bad model detected with error: "Failed to load model: Could not load the model: /tmp/model/0001/model.joblib. No module named sklearn_crfsuite.estimator. (Error code: 0)" 错误:(gcloud.alpha.ml-engine.versions.create)检测到错误的模型,并显示错误:“无法加载模型:无法加载模型:/tmp/model/0001/model.joblib。没有名为sklearn_crfsuite.estimator的模块。(错误代码:0)”

deploy model: gcloud alpha ml-engine versions create v1 --model teste --origin $ORI --python-version 2.7 --runtime-version 1.8 --framework scikit-learn 部署模型:gcloud alpha ml-engine版本创建v1 --model teste --origin $ ORI --python-version 2.7 --runtime-version 1.8 --framework scikit-learn

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM