【问题标题】:Can a custom sklearn model be uploaded to gcloud ml-engine?可以将自定义 sklearn 模型上传到 gcloud ml-engine 吗?
【发布时间】:2018-10-09 17:34:00
【问题描述】:

我已经尝试了按照gcloud tutorial 将 sklearn 模型部署到 ml-engine 的新功能。我为 sklearn Estimator GaussianMixture 创建了一个包装器,以更改预测函数,使其输出概率输出(如 sample_scores)而不是默认的类预测。

GMMWrapper.py

class GMMWrapper(GaussianMixture):
    def predict(self, X):
        return self.score_samples(X)

我创建管道并以标准方式保存它:

gmm = GMMWrapper()
pipegmm = Pipeline([('gmm', gmm)])
pipegmm.fit(data)
with tf.gfile.Open(model_output_path, 'wb') as model_file:
    joblib.dump(pipegmm, model_output_path + '.joblib')

但是,当使用gcloud beta ml-engine versions create 部署到 gcloud 时,它当然找不到模块 GMMWrapper

ERROR: (gcloud.beta.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 'GMMWrapper'.

我已尝试将其包含在部署源文件夹中,该文件夹将上传到暂存存储桶。

DEPLOYMENT_SOURCE="/folder-containing-model-and-GMMWrapper"
MODEL_NAME="GMMs"
FRAMEWORK="SCIKIT_LEARN"
STAGING_BUCKET="gs://sklearn-models"

gcloud beta ml-engine versions create v1 \
    --model $MODEL_NAME --origin $DEPLOYMENT_SOURCE \
    --framework $FRAMEWORK --staging-bucket $STAGING_BUCKET \
    --runtime-version=1.5 --python-version=3.5

但这会返回相同的错误。我需要以某种方式通知 gcloud 在哪里寻找模块。我怀疑这是做不到的,但我想如果有办法我会问。

(或者,如果有一种方法可以更改在管道上调用 predict 时调用的函数,这也可以解决我的问题。)

【问题讨论】:

  • 我们目前正在寻求支持您的用例。如果您能与 cloudml-feedback@google.com 联系,我们将非常高兴,以便我们更好地了解您的使用案例。
  • 当然,我应该在主题行中添加任何具体内容以便您找到它?
  • 不。我们监控所有此类电子邮件:)

标签: scikit-learn pipeline gcloud google-cloud-ml


【解决方案1】:

目前不支持此功能。我们一直在寻找改进产品的方法,并将考虑到这个建议的功能。

【讨论】:

  • 嗨@rhaertel80,有关于此功能请求的更新吗?
  • 这应该会在几周内作为有限预览版提供。如果您有兴趣加入,请发送电子邮件至 cloudml-feedback@google.com。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-04
  • 1970-01-01
相关资源
最近更新 更多