AWS sagemaker documentation change
Summary
Updated documentation to include SageMaker Python SDK v3 examples alongside existing v2 examples for warm start tuning jobs. Added new code snippets for v3 implementation including WarmStartConfig usage, ModelTrainer configuration, and tune() method.
Security assessment
The changes are documentation updates showing new SDK usage patterns. There is no evidence of security vulnerabilities being addressed or security features being documented.
Diff
diff --git a/sagemaker/latest/dg/automatic-model-tuning-warm-start.md b/sagemaker/latest/dg/automatic-model-tuning-warm-start.md index fdeb7cfcd..9eb3527ca 100644 --- a//sagemaker/latest/dg/automatic-model-tuning-warm-start.md +++ b//sagemaker/latest/dg/automatic-model-tuning-warm-start.md @@ -129,0 +130,15 @@ To use the [Amazon SageMaker Python SDK](https://sagemaker.readthedocs.io/en/sta +SageMaker Python SDK v3 + + + * Specify the parent jobs and the warm start type by using a `WarmStartConfig` object. + + * Pass the `WarmStartConfig` object as the value of the `warm_start_config` argument of a [HyperparameterTuner](https://sagemaker.readthedocs.io/en/stable/api/sagemaker_train.html) object. + + * Call the `tune` method of the `HyperparameterTuner` object. + + + + +SageMaker Python SDK v2 (Legacy) + + @@ -148,0 +164,13 @@ The following code configures the warm start tuning job by creating a `WarmStart +SageMaker Python SDK v3 + + + + from sagemaker.train.tuner import WarmStartTypes + from sagemaker.core.shapes import HyperParameterTuningJobWarmStartConfig + + parent_tuning_job_name = "MyParentTuningJob" + warm_start_config = HyperParameterTuningJobWarmStartConfig(warm_start_type=WarmStartTypes.IDENTICAL_DATA_AND_ALGORITHM, parents=[parent_tuning_job_name]) + +SageMaker Python SDK v2 (Legacy) + + @@ -155 +183,29 @@ The following code configures the warm start tuning job by creating a `WarmStart -Now set the values for static hyperparameters, which are hyperparameters that keep the same value for every training job that the warm start tuning job launches. In the following code, `imageclassification` is an estimator that was created previously. +Now set the values for static hyperparameters, which are hyperparameters that keep the same value for every training job that the warm start tuning job launches. In the following code, `imageclassification` is a ModelTrainer that was created previously. + +SageMaker Python SDK v3 + + + + from sagemaker.train import ModelTrainer + from sagemaker.train.configs import Compute + + imageclassification = ModelTrainer( + training_image=training_image, + role=role, + hyperparameters={ + 'num_layers': '18', + 'image_shape': '3,224,224', + 'num_classes': '257', + 'num_training_samples': '15420', + 'mini_batch_size': '128', + 'epochs': '30', + 'optimizer': 'sgd', + 'top_k': '2', + 'precision_dtype': 'float32', + 'augmentation_type': 'crop', + }, + compute=Compute(instance_type='ml.p3.8xlarge', instance_count=1), + ) + +SageMaker Python SDK v2 (Legacy) + @@ -170,0 +227,16 @@ Now create the `HyperparameterTuner` object and pass the `WarmStartConfig` objec +SageMaker Python SDK v3 + + + + tuner_warm_start = HyperparameterTuner(model_trainer=imageclassification, + objective_metric_name='validation:accuracy', + hyperparameter_ranges=hyperparameter_ranges, + objective_type='Maximize', + max_jobs=10, + max_parallel_jobs=2, + base_tuning_job_name='warmstart', + warm_start_config=warm_start_config) + +SageMaker Python SDK v2 (Legacy) + + @@ -181 +253,11 @@ Now create the `HyperparameterTuner` object and pass the `WarmStartConfig` objec -Finally, call the `fit` method of the `HyperparameterTuner` object to launch the warm start tuning job. +Finally, call the `tune` or `fit` method of the `HyperparameterTuner` object to launch the warm start tuning job. + +SageMaker Python SDK v3 + + + + tuner_warm_start.tune( + {'train': s3_input_train, 'validation': s3_input_validation}) + +SageMaker Python SDK v2 (Legacy) +