ml-engine - no module named trainer

♀尐吖头ヾ 提交于 2020-01-16 15:47:27

问题


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.

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?


回答1:


You need to run python setup.py --sdist and then upload dist/trainer.tgz to GCS and use that as --package-uris.




回答2:


I using sklearn_crfsuite estimator

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

deploy model: gcloud alpha ml-engine versions create v1 --model teste --origin $ORI --python-version 2.7 --runtime-version 1.8 --framework scikit-learn



来源:https://stackoverflow.com/questions/51994295/ml-engine-no-module-named-trainer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!