本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
编译模型(亚马逊 A SageMaker I SDK)
您可以使用适用于 Python 的 Amazon SageMaker AI SDKcompile_model
注意
使用 MXNet 或编译模型500
时,必须将MMS_DEFAULT_RESPONSE_TIMEOUT
环境变量设置为 PyTorch。不需要环境变量 TensorFlow。
以下是如何使用 trained_model_estimator
对象编译模型的示例:
# Replace the value of expected_trained_model_input below and # specify the name & shape of the expected inputs for your trained model # in json dictionary form expected_trained_model_input = {'data':[1, 784]} # Replace the example target_instance_family below to your preferred target_instance_family compiled_model = trained_model_estimator.compile_model(target_instance_family='ml_c5', input_shape=expected_trained_model_input, output_path='insert s3 output path', env={'MMS_DEFAULT_RESPONSE_TIMEOUT': '500'})
该代码编译模型,将优化的模型保存在output_path
,然后创建可部署到端点的 SageMaker AI 模型。Neo 模型编译示例笔记本部分提供了使用 Python SDK 的示例笔记本。