選取您的 Cookie 偏好設定

我們使用提供自身網站和服務所需的基本 Cookie 和類似工具。我們使用效能 Cookie 收集匿名統計資料,以便了解客戶如何使用我們的網站並進行改進。基本 Cookie 無法停用,但可以按一下「自訂」或「拒絕」以拒絕效能 Cookie。

如果您同意,AWS 與經核准的第三方也會使用 Cookie 提供實用的網站功能、記住您的偏好設定,並顯示相關內容,包括相關廣告。若要接受或拒絕所有非必要 Cookie,請按一下「接受」或「拒絕」。若要進行更詳細的選擇,請按一下「自訂」。

TensorFlow 架構處理器

焦點模式
TensorFlow 架構處理器 - Amazon SageMaker AI

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

TensorFlow 是一種開放原始碼的機器學習和人工智慧程式庫。Amazon SageMaker Python SDK 中的 TensorFlowProcessor 提供您使用 TensorFlow 指令碼執行處理任務的能力。使用 TensorFlowProcessor 時,您可以運用 Amazon 建置的 Docker 容器與受管 TensorFlow 環境,這樣您就不必使用自己的容器。

下列程式碼範例示範如何使用 SageMaker AI 提供的 Docker 映像來執行TensorFlowProcessor處理任務。請注意,執行任務時,您可以在 source_dir 引數中指定一個包含指令碼和相依性的目錄,而且可以在 source_dir 目錄中擁有一個 requirements.txt 檔案來指定處理指令碼的相依性。SageMaker Processing 會在容器中為您安裝 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 SDK 中的 TensorFlow 估算器

隱私權網站條款Cookie 偏好設定
© 2025, Amazon Web Services, Inc.或其附屬公司。保留所有權利。