python-3.x - sagemaker官方教程是否产生AttributeError,如何解决?
问题描述
我正在关注AWS Sagemaker 教程,但我认为步骤 4a 中有错误。特别是,在第 3 行,我被指示输入:
s3_input_train = sagemaker.s3_input(s3_data='s3://{}/{}/train'.format(bucket_name, prefix), content_type='csv')
我得到了错误
----> 3 s3_input_train = sagemaker.s3_input(s3_data='s3://{}/{}/train'.format(bucket_name, prefix), content_type='csv')
AttributeError: module 'sagemaker' has no attribute 's3_input'
事实上,使用dir
表明 sagemaker 没有名为 s3_input 的属性。如何解决这个问题,以便我可以在教程中继续前进?我尝试使用session.inputs
,但这会将我重定向到一个页面,该页面说session
已弃用并建议我使用sagemaker.inputs.TrainingInput
而不是sagemaker.s3_inputs
. 这是前进的好方法吗?
感谢大家的帮助和耐心!
解决方案
使用sagemaker.inputs.TrainingInput
而不是sagemaker.s3_inputs
工作来使该代码单元发挥作用。这是一个合适的解决方案,尽管可能有另一种方法。
步骤 4.b 也有需要更新的代码
sess = sagemaker.Session()
xgb = sagemaker.estimator.Estimator(containers[my_region],role, train_instance_count=1, train_instance_type='ml.m4.xlarge',output_path='s3://{}/{}/output'.format(bucket_name, prefix),sagemaker_session=sess)
xgb.set_hyperparameters(max_depth=5,eta=0.2,gamma=4,min_child_weight=6,subsample=0.8,silent=0,objective='binary:logistic',num_round=100)
使用参数train_instance_count
并且train_instance_type
在更高版本中已更改(https://sagemaker.readthedocs.io/en/stable/v2.html#parameter-and-class-name-changes)。
进行这些更改解决了使用conda_python3
内核的教程的错误。
推荐阅读
- apache-nifi - 如何通过在 NIFI QueryDataBaseTable 处理器中获取数据进行排序
- java - 如何授予经过身份验证的网站用户(App Engine 标准)访问 Google Cloud Storage 存储桶的权限?
- mysql - 在 where 中使用全文而不是 order by
- android - android Api level 19中不会出现特殊字符
- openedge - 是否可以在 AppBuilder 中连接除 sports2000 之外的数据库?
- r - 我应该如何在 R 中调用 model.frame?
- node.js - Node.js 读取文件,如果存在则追加数据,如果不存在则创建文件
- angular - TypeError:无法在 getAssignmentTargetKind 读取未定义的属性“种类”
- ios - UICollectionViewCell 布局边距永远不会更新
- c# - 从空列表中读取空 DateTime