TensorFlow フレームワークプロセッサ - Amazon SageMaker

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

TensorFlow フレームワークプロセッサ

TensorFlow は、オープンソースの機械学習および人工知能ライブラリです。Amazon SageMaker Python SDK TensorFlowProcessorの では、 TensorFlow スクリプトを使用して処理ジョブを実行できます。を使用するとTensorFlowProcessor、Amazon が構築した Docker コンテナをマネージド TensorFlow 環境で活用できるため、独自のコンテナを持ち込む必要はありません。

次のコード例は、 で提供および保守されている Docker イメージを使用して、 を使用して処理ジョブTensorFlowProcessorを実行する方法を示しています SageMaker。ジョブを実行するときは、 source_dir引数にスクリプトと依存関係を含むディレクトリを指定でき、処理スクリプトの依存関係を指定するrequirements.txtファイルをsource_dirディレクトリ内に配置できます ()。 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 クラスの詳細については、Amazon SageMaker Python SDKTensorFlow 「推定器」を参照してください。