AWS Security ChangesHomeSearch

AWS sagemaker documentation change

Service: sagemaker · 2026-06-28 · Documentation low

File: sagemaker/latest/dg/IC-TF-how-to-use.md

Summary

Updated code examples to use SageMaker Python SDK v3 (ModelTrainer) instead of legacy v2 (Estimator)

Security assessment

The changes are purely SDK version updates and code syntax improvements without any security context, vulnerability fixes, or security feature documentation. No security-related terms or concepts are introduced.

Diff

diff --git a/sagemaker/latest/dg/IC-TF-how-to-use.md b/sagemaker/latest/dg/IC-TF-how-to-use.md
index 9eec26420..9fbc376ba 100644
--- a//sagemaker/latest/dg/IC-TF-how-to-use.md
+++ b//sagemaker/latest/dg/IC-TF-how-to-use.md
@@ -11 +11 @@ You can use Image Classification - TensorFlow as an Amazon SageMaker AI built-in
-The Image Classification - TensorFlow algorithm supports transfer learning using any of the compatible pretrained TensorFlow Hub models. For a list of all available pretrained models, see [TensorFlow Hub Models](./IC-TF-Models.html). Every pretrained model has a unique `model_id`. The following example uses MobileNet V2 1.00 224 (`model_id`: `tensorflow-ic-imagenet-mobilenet-v2-100-224-classification-4`) to fine-tune on a custom dataset. The pretrained models are all pre-downloaded from the TensorFlow Hub and stored in Amazon S3 buckets so that training jobs can run in network isolation. Use these pre-generated model training artifacts to construct a SageMaker AI Estimator.
+The Image Classification - TensorFlow algorithm supports transfer learning using any of the compatible pretrained TensorFlow Hub models. For a list of all available pretrained models, see [TensorFlow Hub Models](./IC-TF-Models.html). Every pretrained model has a unique `model_id`. The following example uses MobileNet V2 1.00 224 (`model_id`: `tensorflow-ic-imagenet-mobilenet-v2-100-224-classification-4`) to fine-tune on a custom dataset. The pretrained models are all pre-downloaded from the TensorFlow Hub and stored in Amazon S3 buckets so that training jobs can run in network isolation. Use these pre-generated model training artifacts to construct a SageMaker AI ModelTrainer.
@@ -13 +13 @@ The Image Classification - TensorFlow algorithm supports transfer learning using
-First, retrieve the Docker image URI, training script URI, and pretrained model URI. Then, change the hyperparameters as you see fit. You can see a Python dictionary of all available hyperparameters and their default values with `hyperparameters.retrieve_default`. For more information, see [Image Classification - TensorFlow Hyperparameters](./IC-TF-Hyperparameter.html). Use these values to construct a SageMaker AI Estimator.
+First, retrieve the Docker image URI, training script URI, and pretrained model URI. Then, change the hyperparameters as you see fit. You can see a Python dictionary of all available hyperparameters and their default values with `hyperparameters.retrieve_default`. For more information, see [Image Classification - TensorFlow Hyperparameters](./IC-TF-Hyperparameter.html). Use these values to construct a SageMaker AI ModelTrainer.
@@ -20,0 +21,61 @@ This example uses the [`tf_flowers`](https://www.tensorflow.org/datasets/catalog
+SageMaker Python SDK v3
+    
+    
+    
+    from sagemaker.core import image_uris
+    from sagemaker.core import model_uris, script_uris, hyperparameters
+    from sagemaker.train import ModelTrainer
+    from sagemaker.train.configs import InputData
+    from sagemaker.train.configs import SourceCode, Compute, StoppingCondition, OutputDataConfig
+    
+    model_id, model_version = "tensorflow-ic-imagenet-mobilenet-v2-100-224-classification-4", "*"
+    training_instance_type = "ml.p3.2xlarge"
+    
+    # Retrieve the Docker image
+    train_image_uri = image_uris.retrieve(model_id=model_id,model_version=model_version,image_scope="training",instance_type=training_instance_type,region=None,framework=None)
+    
+    # Retrieve the training script
+    train_source_uri = script_uris.retrieve(model_id=model_id, model_version=model_version, script_scope="training")
+    
+    # Retrieve the pretrained model tarball for transfer learning
+    train_model_uri = model_uris.retrieve(model_id=model_id, model_version=model_version, model_scope="training")
+    
+    # Retrieve the default hyper-parameters for fine-tuning the model
+    hyperparameters = hyperparameters.retrieve_default(model_id=model_id, model_version=model_version)
+    
+    # [Optional] Override default hyperparameters with custom values
+    hyperparameters["epochs"] = "5"
+    
+    # The sample training data is available in the following S3 bucket
+    training_data_bucket = f"jumpstart-cache-prod-{aws_region}"
+    training_data_prefix = "training-datasets/tf_flowers/"
+    
+    training_dataset_s3_path = f"s3://{training_data_bucket}/{training_data_prefix}"
+    
+    output_bucket = sess.default_bucket()
+    output_prefix = "jumpstart-example-ic-training"
+    s3_output_location = f"s3://{output_bucket}/{output_prefix}/output"
+    
+    # Create SageMaker ModelTrainer instance
+    tf_ic_model_trainer = ModelTrainer(
+        role=aws_role,
+        training_image=train_image_uri,
+        source_code=SourceCode(source_dir=train_source_uri, entry_script="transfer_learning.py"),
+        # In V3, pre-trained model artifacts are passed via input_data_config
+        compute=Compute(instance_type=training_instance_type, instance_count=1),
+        stopping_condition=StoppingCondition(max_runtime_in_seconds=360000),
+        hyperparameters=hyperparameters,
+        output_data_config=OutputDataConfig(s3_output_path=s3_output_location),
+    )
+    
+    # Use S3 path of the training data to launch SageMaker TrainingJob
+    tf_ic_model_trainer.train(
+        input_data_config=[
+            InputData(channel_name="training", data_source=training_dataset_s3_path),
+            InputData(channel_name="model", data_source=train_model_uri),
+        ]
+    )
+
+SageMaker Python SDK v2 (Legacy)
+    
+