選取您的 Cookie 偏好設定

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

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

使用 SageMaker Python SDK 設定資料輸入模式

焦點模式
使用 SageMaker Python SDK 設定資料輸入模式 - Amazon SageMaker AI

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

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

SageMaker Python SDK 提供一般估算器類別適用於機器學習 (ML) 架構的變體,用於啟動訓練工作。您可以在設定 SageMaker AI Estimator類別或 Estimator.fit方法時指定其中一個資料輸入模式。下列程式碼範本顯示兩種指定輸入模式的方法。

使用估算器類別指定輸入模式

from sagemaker.estimator import Estimator from sagemaker.inputs import TrainingInput estimator = Estimator( checkpoint_s3_uri='s3://amzn-s3-demo-bucket/checkpoint-destination/', output_path='s3://amzn-s3-demo-bucket/output-path/', base_job_name='job-name', input_mode='File' # Available options: File | Pipe | FastFile ... ) # Run the training job estimator.fit( inputs=TrainingInput(s3_data="s3://amzn-s3-demo-bucket/my-data/train") )

如需更多資訊,請參閱 SageMaker Python SDK 文件內的 sagemaker.estimator.Estimator 類別。

透過 estimator.fit()方法指定輸入模式

from sagemaker.estimator import Estimator from sagemaker.inputs import TrainingInput estimator = Estimator( checkpoint_s3_uri='s3://amzn-s3-demo-bucket/checkpoint-destination/', output_path='s3://amzn-s3-demo-bucket/output-path/', base_job_name='job-name', ... ) # Run the training job estimator.fit( inputs=TrainingInput( s3_data="s3://amzn-s3-demo-bucket/my-data/train", input_mode='File' # Available options: File | Pipe | FastFile ) )

如需更多資訊,請參閱 SageMaker Python SDK 文件內的sagemaker.estimator.Estimator.fit 類別方法以及 sagemaker.inputs.TrainingInput 類別。

提示

若要進一步了解如何使用 SageMaker Python SDK 估算器搭配 VPC 組態設定 Amazon FSx for Lustre 或 Amazon EFS,請參閱 SageMaker AI Python SDK 文件中的使用檔案系統做為訓練輸入

提示

資料輸入模式與 Amazon S3、Amazon EFS 和 FSx for Lustre 整合,是設定資料來源以獲得最佳實務的最佳建議方式。您可以使用 SageMaker AI 受管儲存選項和輸入模式,以策略方式改善資料載入效能,但沒有嚴格限制。您可以直接在訓練容器中撰寫自己的資料讀取邏輯。例如,您可以設定為從不同的資料來源讀取、撰寫自己的 S3 資料載入器類別,或在訓練指令碼中使用第三方架構的資料載入功能。不過,您必須確定指定 SageMaker AI 可以辨識的正確路徑。

提示

如果您使用自訂訓練容器,請務必安裝 SageMaker 訓練工具組,以協助設定 SageMaker 訓練工作的環境。否則,您必須在 Dockerfile 中明確指定環境變數。如需更多資訊,請參閱使用自有的演算法和模型建立容器

有關如何使用低階 SageMaker API 設定資料輸入模式的更多相關資訊Amazon SageMaker AI 如何提供訓練資訊,請參閱 ,CreateTrainingJob API 和 AlgorithmSpecification 內的 TrainingInputMode

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