首页 > 解决方案 > SageMaker TensorFlow Estimator 源码 S3 上传路径

问题描述

我正在使用 SageMaker TensorFlow 估计器进行训练,并使用参数为我的模型工件指定输出路径output_path,其值为s3://<bucket>/<prefix>/.

模型训练完成后,<training_job_name>/output在指定的output_path.

我遇到的问题是,用于训练的源代码也默认上传到 S3,但不是s3://<bucket>/<prefix>/<training_job_name>/source放在s3://<bucket>/<training_job_name>/source.

那么如何为训练作业的源代码指定 S3 上传路径,以使其使用存储桶和前缀名称output_path

标签: tensorflowamazon-s3uploadamazon-sagemaker

解决方案


您是否尝试过使用“code_location”参数:https ://sagemaker.readthedocs.io/en/stable/estimators.html来指定源代码的位置?

下面是使用 code_location 的代码片段示例

from sagemaker.tensorflow import TensorFlow

code-path = "s3://<bucket>/<prefix>"
output-path = "s3://<bucket>/<prefix>"

abalone_estimator = TensorFlow(entry_point='abalone.py',
                           role=role,
                           framework_version='1.12.0',
                           training_steps= 100, 
                           image_name=image,
                           evaluation_steps= 100,
                           hyperparameters={'learning_rate': 0.001},
                           train_instance_count=1,
                           train_instance_type='ml.c4.xlarge',
                           code_location= code-path,
                           output_path = output-path,
                           base_job_name='my-job-name'
                           )

推荐阅读