AWS Sagemaker SKlearn 入口点允许多个脚本 [英] AWS Sagemaker SKlearn entry point allow multiple script

查看:19
本文介绍了AWS Sagemaker SKlearn 入口点允许多个脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按照教程 此处 实现用于特征预处理的自定义推理管道.它使用 python sklearn sdk 从脚本中引入自定义预处理管道.例如:

I am trying to follow the tutorial here to implement a custom inference pipeline for feature preprocessing. It uses the python sklearn sdk to bring in custom preprocessing pipeline from a script. For example:

from sagemaker.sklearn.estimator import SKLearn

script_path = 'preprocessing.py'

sklearn_preprocessor = SKLearn(
    entry_point=script_path,
    role=role,
    train_instance_type="ml.c4.xlarge",
    sagemaker_session=sagemaker_session)

但是我找不到发送多个文件的方法.我需要多个文件的原因是因为我有一个在 sklearn 管道中使用的自定义类需要从自定义模块导入.如果没有导入,它会引发错误 AttributeError: module '__main__' has no attribute 'CustomClassName' 由于 pickle 的工作方式(至少我认为它是相关的)在同一个 preprocessing.py 文件中拥有自定义类腌制).

However I can't find a way to send multiple files. The reason I need multiple files is because I have a custom class used in the sklearn pipeline needs to be imported from a custom module. Without importing, it raises error AttributeError: module '__main__' has no attribute 'CustomClassName' when having the custom class in the same preprocessing.py file due to the way pickle works (at least I think it's related to pickle).

有人知道是否可以发送多个文件吗?

Anyone know if sending multiple files is even possible?

Sagemaker 新手,谢谢!!

Newbie to Sagemaker, thanks!!

推荐答案

有一个 source_dir 参数,它会将文件目录提升"到容器中,并将其放在您的导入路径中.

There's a source_dir parameter which will "lift" a directory of files to the container and put it on your import path.

您的入口点脚本应该放在那里并从该位置引用.

You're entrypoint script should be put there to and referenced from that location.

这篇关于AWS Sagemaker SKlearn 入口点允许多个脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆