我正在尝试按照教程here来实现一个自定义的推理管道,用于特征预处理。它使用python sklearn sdk从脚本引入自定义预处理管道。例如:
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管道中使用的自定义类需要从一个自定义模块导入。如果不导入,由于pickle的工作方式(至少我认为它与pickle相关),在同一个preprocessing.py文件中包含自定义类时会引发错误AttributeError: module '__main__' has no attribute 'CustomClassName'。
有人知道是否可以发送多个文件吗?
新手到Sagemaker,谢谢!
发布于 2019-01-23 21:43:42
有一个source_dir参数可以将文件的目录“提升”到容器中,并将其放到导入路径中。
你的入口点脚本应该放在那里,并从那个位置引用。
发布于 2021-10-19 15:19:59
您还可以在SKLearn中使用dependencies参数。例如:
sklearn_preprocessor = SKLearn(
entry_point=script_path,
role=role,
train_instance_type="ml.c4.xlarge",
sagemaker_session=sagemaker_session,
dependencies=['script1.py', 'script2.py']
)https://stackoverflow.com/questions/54314876
复制相似问题