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'
实际上, usingdir表明 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内核的教程的错误。
THE END
二维码