TensorFlow 框架处理器 - Amazon SageMaker

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

TensorFlow 框架处理器

TensorFlow 是一个开源的机器学习和人工智能库。Amaz SageMaker on Python 软件开发工具包TensorFlowProcessor中的使您能够使用 TensorFlow 脚本运行处理任务。使用时TensorFlowProcessor,您可以利用亚马逊构建的带有托管 TensorFlow 环境的 Docker 容器,这样您就无需自带容器。

以下代码示例说明了如何使用提供和维护的 Docker 镜像来运行处理作业。TensorFlowProcessor SageMaker请注意,当你运行作业时,你可以在source_dir参数中指定一个包含脚本和依赖关系的目录,也可以在你的source_dir目录中有一个requirements.txt文件来指定处理脚本的依赖关系。 SageMaker 处理会为您在容器requirements.txt中安装依赖项。

from sagemaker.tensorflow import TensorFlowProcessor from sagemaker.processing import ProcessingInput, ProcessingOutput from sagemaker import get_execution_role #Initialize the TensorFlowProcessor tp = TensorFlowProcessor( framework_version='2.3', role=get_execution_role(), instance_type='ml.m5.xlarge', instance_count=1, base_job_name='frameworkprocessor-TF', py_version='py37' ) #Run the processing job tp.run( code='processing-script.py', source_dir='scripts', inputs=[ ProcessingInput( input_name='data', source=f's3://{BUCKET}/{S3_INPUT_PATH}', destination='/opt/ml/processing/input/data' ), ProcessingInput( input_name='model', source=f's3://{BUCKET}/{S3_PATH_TO_MODEL}', destination='/opt/ml/processing/input/model' ) ], outputs=[ ProcessingOutput( output_name='predictions', source='/opt/ml/processing/output', destination=f's3://{BUCKET}/{S3_OUTPUT_PATH}' ) ] )

如果您有 requirements.txt 文件,它应该是您要在容器中安装的库的列表。source_dir 的路径可以是相对路径、绝对路径或 Amazon S3 URI 路径。但是,如果您使用 Amazon S3 URI,则路径必须指向 tar.gz 文件。在您为 source_dir 指定的目录中可以有多个脚本。要了解有关该TensorFlowProcessor课程的更多信息,请参阅 Amaz on Pyth SageMaker on TensorFlow 软件开发工具包中的估算器