

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

# Compila un modello (Amazon SageMaker AI SDK)
<a name="neo-job-compilation-sagemaker-sdk"></a>

 Puoi utilizzare l'[https://sagemaker.readthedocs.io/en/stable/api/training/estimators.html?#sagemaker.estimator.Estimator.compile_model](https://sagemaker.readthedocs.io/en/stable/api/training/estimators.html?#sagemaker.estimator.Estimator.compile_model)API nell'[SDK Amazon SageMaker AI per Python per](https://sagemaker.readthedocs.io/en/stable/) compilare un modello addestrato e ottimizzarlo per hardware di destinazione specifico. L'API deve essere richiamata sull'oggetto dello strumento di valutazione utilizzato durante l'addestramento del modello. 

**Nota**  
È necessario impostare la variabile di `MMS_DEFAULT_RESPONSE_TIMEOUT` ambiente su `500` quando si compila il modello con o. MXNet PyTorch La variabile di ambiente non è necessaria per TensorFlow. 

 Di seguito è riportato un esempio di come è possibile compilare un modello utilizzando l'oggetto `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'})
```

Il codice compila il modello, salva il modello ottimizzato in `output_path` e crea un modello di SageMaker intelligenza artificiale che può essere distribuito su un endpoint. 