[英]How to save Tensorflow model in S3 (as /output/model.tar.gz) when using Tensorflow Estimator in AWS Sagemaker
[英]SageMaker TensorFlow Estimator source code S3 upload path
我正在使用SageMaker TensorFlow估計器進行訓練,並使用output_path
參數為我的模型工件指定一個輸出路徑,其值為s3://<bucket>/<prefix>/
。
模型訓練后,在指定的output_path
創建一個名為<training_job_name>/output
的目錄。
我遇到的問題是,用於訓練的源代碼也默認情況下也上載到S3,但不是放置在s3://<bucket>/<prefix>/<training_job_name>/source
,而是放置在s3://<bucket>/<training_job_name>/source
。
因此,如何為訓練作業的源代碼指定S3上傳路徑,以使其使用output_path
的存儲桶AND前綴名稱?
您是否嘗試過使用“ 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'
)
我相信@ user3458797顯示的code_location參數是正確的答案。
output_path僅配置S3位置以保存訓練結果(模型工件和輸出文件)。
https://sagemaker.readthedocs.io/en/stable/estimators.html
除非您在培訓期間將文件移至/ opt / ml / model或使用code_location參數,否則您的培訓腳本不會保存在“ output_path”中。
請讓我知道是否有任何需要澄清的內容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.