Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Mengkompilasi Model (Amazon SageMaker AI SDK)
Anda dapat menggunakan compile_model
catatan
Anda harus menyet MMS_DEFAULT_RESPONSE_TIMEOUT el variabel lingkungan ke 500 saat mengkompilasi model dengan MXnet atau. PyTorch Variabel lingkungan tidak diperlukan untuk TensorFlow.
Berikut ini adalah contoh bagaimana Anda dapat mengkompilasi model menggunakan trained_model_estimator objek:
# Neo compilation in V3 uses ModelBuilder.optimize() with compilation_config from sagemaker.serve import ModelBuilder # 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 model_builder = ModelBuilder( model=trained_model, role_arn=role, instance_type='ml.c5.xlarge', ) optimized_model = model_builder.optimize( instance_type='ml.c5.xlarge', output_path='insert s3 output path', compilation_config={ 'OverrideEnvironment': { 'OPTION_TARGET_INSTANCE_FAMILY': 'ml_c5', 'MMS_DEFAULT_RESPONSE_TIMEOUT': '500', }, }, )
Kode mengkompilasi model, menyimpan model yang dioptimalkan dioutput_path, dan membuat model SageMaker AI yang dapat digunakan ke titik akhir.