繁体   English   中英

创建版本失败。 错误模型检测到错误:“...没有名为 'sklearn.impute._base' 的模块;'sklearn.impute' 不是包。(错误代码:0)”

[英]Create Version failed. Bad model detected with error: "... No module named 'sklearn.impute._base'; 'sklearn.impute' is not a package. (Error code: 0)"

我正在尝试在 google cloud ai 平台上创建一个版本,但找不到 impute 模块

No module named 'sklearn.impute._base; 'sklearn.impute' is not a package

在此处输入图片说明 框架版本是 sklearn 0.20.4,最后我检查了文档 0.20.4 有 sklearn.impute api。

第 1785 页https://scikit-learn.org/0.20//_downloads/scikit-learn-docs.pdf

整个 sklearn 包是否包含在 ai 平台中? 是否有解决方法(真的不想编写自定义输入器)还是我使用的 AI 平台有误?

scikit-learn 0.20.4 包含在最新的运行时版本1.15和旧版本中。

来自 scikit-learn 文档: https ://scikit-learn.org/stable/modules/generated/sklearn.impute.SimpleImputer.html 该函数包含在 0.20.4 中:

我在本地尝试使用 Python 3.5/3.7 并调用该方法工作正常:

...
scikit-learn==0.20.4
scipy==1.4.1
six==1.14.0
tensorboard==1.15.0
tensorflow==1.15.2
tensorflow-estimator==1.15.1
termcolor==1.1.0
Werkzeug==0.16.1
wrapt==1.11.2

...
>>> import numpy as np
>>> from sklearn.impute import SimpleImputer
>>> imp_mean = SimpleImputer(missing_values=np.nan, strategy='mean')
>>> imp_mean.fit([[7, 2, 3], [4, np.nan, 6], [10, 5, 9]])
SimpleImputer(copy=True, fill_value=None, missing_values=nan, strategy='mean',
       verbose=0)

AI Platform Training and Prediction API 使用的默认 AI Platform Training 运行时版本是 1.0 版。 如果您未指定运行时版本,AI Platform Training 将使用版本 1.0。

确保在启动作业时设置正确的运行时版本:

gcloud ai-platform jobs submit training my_job \
    --module-name trainer.task \
    --job-dir gs://my/training/job/directory \
    --package-path /path/to/my/project/trainer \
    --region us-central1
    --runtime-version 1.15

问题:您能分享一下您是如何启动作业和设置运行时版本的吗?

我过去遇到过类似的问题。 sklearn 包包含在 AI 平台中,但是,如果您使用与 AI 平台使用的版本不同的版本训练模型,则需要返回并使用与 AI 相同的 scikit-learn 版本重新训练模型平台的运行时正在使用。

希望这可以帮助!

暂无
暂无

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

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