選取您的 Cookie 偏好設定

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

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

使用陰影變體測試模型

焦點模式
使用陰影變體測試模型 - Amazon SageMaker AI

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

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

您可以使用 SageMaker AI Model Shadow Deployments 來建立長時間執行的陰影變體,在將模型服務堆疊的任何新候選元件提升至生產環境之前,驗證其內容。下圖顯示更詳細的陰影收體運作情形。

陰影變體的詳細資訊。

部署陰影變體

下列程式碼範例示範如何以程式設計方式部署陰影變體。請將範例中的使用者預留位置文字取代為您自己的資訊。

  1. 建立兩個 SageMaker AI 模型:一個用於生產變體,另一個用於陰影變體。

    import boto3 from sagemaker import get_execution_role, Session aws_region = "aws-region" boto_session = boto3.Session(region_name=aws_region) sagemaker_client = boto_session.client("sagemaker") role = get_execution_role() bucket = Session(boto_session).default_bucket() model_name1 = "name-of-your-first-model" model_name2 = "name-of-your-second-model" sagemaker_client.create_model( ModelName = model_name1, ExecutionRoleArn = role, Containers=[ { "Image": "ecr-image-uri-for-first-model", "ModelDataUrl": "s3-location-of-trained-first-model" } ] ) sagemaker_client.create_model( ModelName = model_name2, ExecutionRoleArn = role, Containers=[ { "Image": "ecr-image-uri-for-second-model", "ModelDataUrl": "s3-location-of-trained-second-model" } ] )
  2. 建立端點組態。在組態中指定生產和陰影變體。

    endpoint_config_name = name-of-your-endpoint-config create_endpoint_config_response = sagemaker_client.create_endpoint_config( EndpointConfigName=endpoint_config_name, ProductionVariants=[ { "VariantName": name-of-your-production-variant, "ModelName": model_name1, "InstanceType": "ml.m5.xlarge", "InitialInstanceCount": 1, "InitialVariantWeight": 1, } ], ShadowProductionVariants=[ { "VariantName": name-of-your-shadow-variant, "ModelName": model_name2, "InstanceType": "ml.m5.xlarge", "InitialInstanceCount": 1, "InitialVariantWeight": 1, } ] )
  3. 建立端點。

    create_endpoint_response = sm.create_endpoint( EndpointName=name-of-your-endpoint, EndpointConfigName=endpoint_config_name, )
隱私權網站條款Cookie 偏好設定
© 2025, Amazon Web Services, Inc.或其附屬公司。保留所有權利。