AWS sagemaker documentation change
Summary
Removed legacy SageMaker Python SDK v2 code examples and documentation throughout the training workflow guide
Security assessment
The changes exclusively remove outdated SDK v2 examples without adding new security content or addressing vulnerabilities. No security-related terms, vulnerabilities, or mitigations are mentioned in the removed content. The removal appears to be routine documentation maintenance.
Diff
diff --git a/sagemaker/latest/dg/ex1-train-model.md b/sagemaker/latest/dg/ex1-train-model.md index 05256bd8f..d8aa19c0e 100644 --- a//sagemaker/latest/dg/ex1-train-model.md +++ b//sagemaker/latest/dg/ex1-train-model.md @@ -38,3 +37,0 @@ After you figured out which model to use, start constructing a training job. Thi -SageMaker Python SDK v3 - - @@ -58,19 +54,0 @@ If you run this installation in your exiting SageMaker Studio or notebook instan -SageMaker Python SDK v2 (Legacy) - - - import sagemaker - - region = sagemaker.Session().boto_region_name - print("AWS Region: {}".format(region)) - - role = sagemaker.get_execution_role() - print("RoleArn: {}".format(role)) - -###### Note - -Check the SageMaker Python SDK version by running `sagemaker.__version__`. This tutorial is based on `sagemaker>=2.20`. If the SDK is outdated, install the latest version by running the following command: - - ! pip install -qU sagemaker - -If you run this installation in your exiting SageMaker Studio or notebook instances, you need to manually refresh the kernel to finish applying the version update. - @@ -85,3 +62,0 @@ This returns the following information: -SageMaker Python SDK v3 - - @@ -131,55 +105,0 @@ To construct the SageMaker AI `ModelTrainer`, specify the following parameters: -SageMaker Python SDK v2 (Legacy) - - -Create an XGBoost estimator using the `sagemaker.estimator.Estimator` class. In the following example code, the XGBoost estimator is named `xgb_model`. - - from sagemaker.debugger import Rule, ProfilerRule, rule_configs - from sagemaker.session import TrainingInput - - s3_output_location='s3://{}/{}/{}'.format(bucket, prefix, 'xgboost_model') - - container=sagemaker.image_uris.retrieve("xgboost", region, "1.2-1") - print(container) - - xgb_model=sagemaker.estimator.Estimator( - image_uri=container, - role=role, - instance_count=1, - instance_type='ml.m4.xlarge', - volume_size=5, - output_path=s3_output_location, - sagemaker_session=sagemaker.Session(), - rules=[ - Rule.sagemaker(rule_configs.create_xgboost_report()), - ProfilerRule.sagemaker(rule_configs.ProfilerReport()) - ] - ) - -To construct the SageMaker AI estimator, specify the following parameters: - - * `image_uri` – Specify the training container image URI. In this example, the SageMaker AI XGBoost training container URI is specified using `sagemaker.image_uris.retrieve`. - - * `role` – The AWS Identity and Access Management (IAM) role that SageMaker AI uses to perform tasks on your behalf (for example, reading training results, call model artifacts from Amazon S3, and writing training results to Amazon S3). - - * `instance_count` and `instance_type` – The type and number of Amazon EC2 ML compute instances to use for model training. For this training exercise, you use a single `ml.m4.xlarge` instance, which has 4 CPUs, 16 GB of memory, an Amazon Elastic Block Store (Amazon EBS) storage, and a high network performance. For more information about EC2 compute instance types, see [Amazon EC2 Instance Types](https://aws.amazon.com/ec2/instance-types/). For more information about billing, see [Amazon SageMaker pricing](https://aws.amazon.com/sagemaker/pricing/). - - * `volume_size` – The size, in GB, of the EBS storage volume to attach to the training instance. This must be large enough to store training data if you use `File` mode (`File` mode is on by default). If you don't specify this parameter, its value defaults to 30. - - * `output_path` – The path to the S3 bucket where SageMaker AI stores the model artifact and training results. - - * `sagemaker_session` – The session object that manages interactions with SageMaker API operations and other AWS service that the training job uses. - - * `rules` – Specify a list of SageMaker Debugger built-in rules. In this example, the `create_xgboost_report()` rule creates an XGBoost report that provides insights into the training progress and results, and the `ProfilerReport()` rule creates a report regarding the EC2 compute resource utilization. For more information, see [SageMaker Debugger interactive report for XGBoost](./debugger-report-xgboost.html). - -Set the hyperparameters for the XGBoost algorithm by calling the `set_hyperparameters` method of the estimator. For a complete list of XGBoost hyperparameters, see [XGBoost hyperparameters](./xgboost_hyperparameters.html). - - xgb_model.set_hyperparameters( - max_depth = 5, - eta = 0.2, - gamma = 4, - min_child_weight = 6, - subsample = 0.7, - objective = "binary:logistic", - num_round = 1000 - ) - @@ -196,3 +115,0 @@ You can also tune the hyperparameters using the SageMaker AI hyperparameter opti -SageMaker Python SDK v3 - - @@ -212,14 +128,0 @@ Use the `InputData` class to configure a data input flow for training. The follo -SageMaker Python SDK v2 (Legacy) - - -Use the `TrainingInput` class to configure a data input flow for training. The following example code shows how to configure `TrainingInput` objects to use the training and validation datasets you uploaded to Amazon S3 in the [Split the Dataset into Train, Validation, and Test Datasets](./ex1-preprocess-data.html#ex1-preprocess-data-transform) section. - - from sagemaker.session import TrainingInput - - train_input = TrainingInput( - "s3://{}/{}/{}".format(bucket, prefix, "data/train.csv"), content_type="csv" - ) - validation_input = TrainingInput( - "s3://{}/{}/{}".format(bucket, prefix, "data/validation.csv"), content_type="csv" - ) - @@ -228,3 +130,0 @@ Use the `TrainingInput` class to configure a data input flow for training. The f -SageMaker Python SDK v3 - - @@ -235,7 +134,0 @@ To start model training, call the trainer's `train` method with the training and -SageMaker Python SDK v2 (Legacy) - - -To start model training, call the estimator's `fit` method with the training and validation datasets. By setting `wait=True`, the `fit` method displays progress logs and waits until training is complete. - - xgb_model.fit({"train": train_input, "validation": validation_input}, wait=True) - @@ -250,3 +142,0 @@ Run the following code to specify the S3 bucket URI where the Debugger training -SageMaker Python SDK v3 - - @@ -257,6 +146,0 @@ SageMaker Python SDK v3 -SageMaker Python SDK v2 (Legacy) - - - rule_output_path = xgb_model.output_path + "/" + xgb_model.latest_training_job.job_name + "/rule-output" - ! aws s3 ls {rule_output_path} --recursive - @@ -274,3 +157,0 @@ The following IPython script returns the file link of the Debugger profiling rep -SageMaker Python SDK v3 - - @@ -287,9 +167,0 @@ SageMaker Python SDK v3 -SageMaker Python SDK v2 (Legacy) - - - profiler_report_name = [rule["RuleConfigurationName"] - for rule in xgb_model.latest_training_job.rule_job_summary() - if "Profiler" in rule["RuleConfigurationName"]][0] - profiler_report_name - display("Click link below to view the profiler report", FileLink(profiler_report_name+"/profiler-output/profiler-report.html")) - @@ -307,3 +178,0 @@ You now have a trained XGBoost model. SageMaker AI stores the model artifact in -SageMaker Python SDK v3 - - @@ -313,6 +181,0 @@ SageMaker Python SDK v3 -SageMaker Python SDK v2 (Legacy) - - - - xgb_model.model_data -