Skip to content

Commit bee835d

Browse files
authored
Merge branch 'master' into mnist-download
2 parents 8b8686f + 34532e4 commit bee835d

File tree

45 files changed

+4877
-161
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+4877
-161
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ assignees: ''
88
---
99

1010
**Link to the notebook**
11-
Add the link to the notebook
11+
Add the link to the notebook.
1212

1313
**Describe the bug**
1414
A clear and concise description of what the bug is.
15+
Attach error logs if available.
16+
For security, make sure you remove or hide your
17+
12-digit AWS account ID when attaching the logs.
1518

1619
**To Reproduce**
17-
Steps to reproduce
20+
Steps to reproduce.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ These examples show you how to use model-packages and algorithms from AWS Market
207207
- [Using models for identifying non-compliance at a workplace](aws_marketplace/using_model_packages/improving_industrial_workplace_safety) provides a detailed walkthrough on how to use pre-trained models from AWS Marketplace for extracting metadata for a sample use-case of generating summary reports for identifying non-compliance at a construction/industrial workplace.
208208
- [Creative writing using GPT-2 Text Generation](aws_marketplace/using_model_packages/creative-writing-using-gpt-2-text-generation) will show you how to use AWS Marketplace GPT-2-XL pre-trained model on Amazon SageMaker to generate text based on your prompt to help you author prose and poetry.
209209
- [Amazon Augmented AI with AWS Marketplace ML models](aws_marketplace/using_model_packages/amazon_augmented_ai_with_aws_marketplace_ml_models) will show you how to use AWS Marketplace pre-trained ML models with Amazon Augmented AI to implement human-in-loop workflow reviews with your ML model predictions.
210-
210+
- [Monitoring data quality in third-party models from AWS Marketplace](aws_marketplace/using_model_packages/data_quality_monitoring) will show you how to perform Data Quality monitoring on a pre-trained third-party model from AWS Marketplace.
211211

212212
### Under Development
213213

aws_marketplace/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ These examples show you how to use model-packages and algorithms from AWS Market
3535
- [Using models for identifying non-compliance at a workplace](using_model_packages/improving_industrial_workplace_safety) provides a detailed walkthrough on how to use pre-trained models from AWS Marketplace for extracting metadata for a sample use-case of generating summary reports for identifying non-compliance at a construction/industrial workplace.
3636
- [Creative writing using GPT-2 Text Generation](using_model_packages/creative-writing-using-gpt-2-text-generation) will show you how to use AWS Marketplace GPT-2-XL pre-trained model on Amazon SageMaker to generate text based on your prompt to help you author prose and poetry.
3737
- [Amazon Augmented AI with AWS Marketplace ML models](using_model_packages/amazon_augmented_ai_with_aws_marketplace_ml_models) will show you how to use AWS Marketplace pre-trained ML models with Amazon Augmented AI to implement human-in-loop workflow reviews with your ML model predictions.
38+
- [Monitoring data quality in third-party models from AWS Marketplace](using_model_packages/data_quality_monitoring) will show you how to perform Data Quality monitoring on a pre-trained third-party model from AWS Marketplace.
3839

3940
## FAQ
4041

aws_marketplace/using_model_packages/data_quality_monitoring/data/baseline.csv

Lines changed: 301 additions & 0 deletions
Large diffs are not rendered by default.

aws_marketplace/using_model_packages/data_quality_monitoring/data/data_quality_drift.csv

Lines changed: 320 additions & 0 deletions
Large diffs are not rendered by default.

aws_marketplace/using_model_packages/data_quality_monitoring/monitoring_data_quality_of_models.ipynb

Lines changed: 776 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class ModelPackageArnProvider:
2+
3+
@staticmethod
4+
def get_model_package_arn(current_region):
5+
mapping = {
6+
"us-east-1" : "arn:aws:sagemaker:us-east-1:865070037744:model-package/planning-to-buy-house-basic-28fcb3ca751705854a7171b255d8ef43",
7+
"us-east-2" : "arn:aws:sagemaker:us-east-2:057799348421:model-package/planning-to-buy-house-basic-28fcb3ca751705854a7171b255d8ef43",
8+
"us-west-1" : "arn:aws:sagemaker:us-west-1:382657785993:model-package/planning-to-buy-house-basic-28fcb3ca751705854a7171b255d8ef43",
9+
"us-west-2" : "arn:aws:sagemaker:us-west-2:594846645681:model-package/planning-to-buy-house-basic-28fcb3ca751705854a7171b255d8ef43",
10+
"ca-central-1" : "arn:aws:sagemaker:ca-central-1:470592106596:model-package/planning-to-buy-house-basic-28fcb3ca751705854a7171b255d8ef43",
11+
"eu-central-1" : "arn:aws:sagemaker:eu-central-1:446921602837:model-package/planning-to-buy-house-basic-28fcb3ca751705854a7171b255d8ef43",
12+
"eu-west-1" : "arn:aws:sagemaker:eu-west-1:985815980388:model-package/planning-to-buy-house-basic-28fcb3ca751705854a7171b255d8ef43",
13+
"eu-west-2" : "arn:aws:sagemaker:eu-west-2:856760150666:model-package/planning-to-buy-house-basic-28fcb3ca751705854a7171b255d8ef43",
14+
"eu-west-3" : "arn:aws:sagemaker:eu-west-3:843114510376:model-package/planning-to-buy-house-basic-28fcb3ca751705854a7171b255d8ef43",
15+
"eu-north-1" : "arn:aws:sagemaker:eu-north-1:136758871317:model-package/planning-to-buy-house-basic-28fcb3ca751705854a7171b255d8ef43",
16+
"ap-southeast-1" : "arn:aws:sagemaker:ap-southeast-1:192199979996:model-package/planning-to-buy-house-basic-28fcb3ca751705854a7171b255d8ef43",
17+
"ap-southeast-2" : "arn:aws:sagemaker:ap-southeast-2:666831318237:model-package/planning-to-buy-house-basic-28fcb3ca751705854a7171b255d8ef43",
18+
"ap-northeast-2" : "arn:aws:sagemaker:ap-northeast-2:745090734665:model-package/planning-to-buy-house-basic-28fcb3ca751705854a7171b255d8ef43",
19+
"ap-northeast-1" : "arn:aws:sagemaker:ap-northeast-1:977537786026:model-package/planning-to-buy-house-basic-28fcb3ca751705854a7171b255d8ef43",
20+
"ap-south-1" : "arn:aws:sagemaker:ap-south-1:077584701553:model-package/planning-to-buy-house-basic-28fcb3ca751705854a7171b255d8ef43",
21+
"sa-east-1" : "arn:aws:sagemaker:sa-east-1:270155090741:model-package/planning-to-buy-house-basic-28fcb3ca751705854a7171b255d8ef43"
22+
}
23+
return mapping[current_region]

aws_sagemaker_studio/introduction_to_amazon_algorithms/xgboost_abalone/xgboost_abalone_dist_script_mode.ipynb

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"metadata": {},
4848
"outputs": [],
4949
"source": [
50-
"# ensure sagemaker version >= 1.35.0\n",
50+
"# ensure sagemaker version >= 2.00.0\n",
5151
"!pip show sagemaker"
5252
]
5353
},
@@ -358,7 +358,7 @@
358358
"\n",
359359
"* __entry_point__: The path to the Python script SageMaker runs for training and prediction.\n",
360360
"* __role__: Role ARN\n",
361-
"* __train_instance_type__ *(optional)*: The type of SageMaker instances for training. __Note__: Because Scikit-learn does not natively support GPU training, Sagemaker Scikit-learn does not currently support training on GPU instance types.\n",
361+
"* __instance_type__ *(optional)*: The type of SageMaker instances for training. __Note__: Because Scikit-learn does not natively support GPU training, Sagemaker Scikit-learn does not currently support training on GPU instance types.\n",
362362
"* __sagemaker_session__ *(optional)*: The session used to train on Sagemaker.\n",
363363
"* __hyperparameters__ *(optional)*: A dictionary passed to the train function as hyperparameters."
364364
]
@@ -391,7 +391,7 @@
391391
"outputs": [],
392392
"source": [
393393
"# Open Source distributed script mode\n",
394-
"from sagemaker.session import s3_input, Session\n",
394+
"from sagemaker.session import TrainingInput, Session\n",
395395
"from sagemaker.xgboost.estimator import XGBoost\n",
396396
"\n",
397397
"boto_session = boto3.Session(region_name=region)\n",
@@ -403,12 +403,12 @@
403403
" framework_version='0.90-1', # Note: framework_version is mandatory\n",
404404
" hyperparameters=hyperparams,\n",
405405
" role=role,\n",
406-
" train_instance_count=2, \n",
407-
" train_instance_type=instance_type,\n",
406+
" instance_count=2, \n",
407+
" instance_type=instance_type,\n",
408408
" output_path=output_path)\n",
409409
"\n",
410-
"train_input = s3_input(\"s3://{}/{}/{}/\".format(bucket, prefix, 'train'), content_type=content_type)\n",
411-
"validation_input = s3_input(\"s3://{}/{}/{}/\".format(bucket, prefix, 'validation'), content_type=content_type)"
410+
"train_input = TrainingInput(\"s3://{}/{}/{}/\".format(bucket, prefix, 'train'), content_type=content_type)\n",
411+
"validation_input = TrainingInput(\"s3://{}/{}/{}/\".format(bucket, prefix, 'validation'), content_type=content_type)"
412412
]
413413
},
414414
{
@@ -449,9 +449,11 @@
449449
"metadata": {},
450450
"outputs": [],
451451
"source": [
452+
"from sagemaker.serializers import CSVSerializer\n",
453+
"\n",
452454
"predictor = xgb_script_mode_estimator.deploy(initial_instance_count=1, \n",
453-
" instance_type=\"ml.m5.2xlarge\")\n",
454-
"predictor.serializer = str"
455+
" instance_type=\"ml.m5.2xlarge\",\n",
456+
" serializer=CSVSerializer())"
455457
]
456458
},
457459
{
@@ -496,6 +498,13 @@
496498
"source": [
497499
"xgb_script_mode_estimator.delete_endpoint()"
498500
]
501+
},
502+
{
503+
"cell_type": "code",
504+
"execution_count": null,
505+
"metadata": {},
506+
"outputs": [],
507+
"source": []
499508
}
500509
],
501510
"metadata": {
@@ -504,7 +513,7 @@
504513
"kernelspec": {
505514
"display_name": "Python 3 (Data Science)",
506515
"language": "python",
507-
"name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-west-2:236514542706:image/datascience-1.0"
516+
"name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-east-1:081325390199:image/datascience-1.0"
508517
},
509518
"language_info": {
510519
"codemirror_mode": {

aws_sagemaker_studio/introduction_to_amazon_algorithms/xgboost_abalone/xgboost_managed_spot_training.ipynb

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@
9191
"metadata": {},
9292
"outputs": [],
9393
"source": [
94-
"from sagemaker.amazon.amazon_estimator import get_image_uri\n",
95-
"container = get_image_uri(region, 'xgboost', '0.90-1')"
94+
"from sagemaker.image_uris import retrieve\n",
95+
"container = retrieve('xgboost', boto3.Session().region_name, '0.90-1')"
9696
]
9797
},
9898
{
@@ -108,7 +108,7 @@
108108
"* __entry_point__: The path to the Python script SageMaker runs for training and prediction.\n",
109109
"* __role__: Role ARN\n",
110110
"* __hyperparameters__: A dictionary passed to the train function as hyperparameters.\n",
111-
"* __train_instance_type__ *(optional)*: The type of SageMaker instances for training. __Note__: This particular mode does not currently support training on GPU instance types.\n",
111+
"* __instance_type__ *(optional)*: The type of SageMaker instances for training. __Note__: This particular mode does not currently support training on GPU instance types.\n",
112112
"* __sagemaker_session__ *(optional)*: The session used to train on Sagemaker."
113113
]
114114
},
@@ -141,15 +141,15 @@
141141
"\n",
142142
"To enable checkpointing for Managed Spot Training using SageMaker XGBoost we need to configure three things: \n",
143143
"\n",
144-
"1. Enable the `train_use_spot_instances` constructor arg - a simple self-explanatory boolean. \n",
144+
"1. Enable the `use_spot_instances` constructor arg - a simple self-explanatory boolean. \n",
145145
"\n",
146-
"2. Set the `train_max_wait constructor` arg - this is an int arg representing the amount of time you are willing to wait for Spot infrastructure to become available. Some instance types are harder to get at Spot prices and you may have to wait longer. You are not charged for time spent waiting for Spot infrastructure to become available, you're only charged for actual compute time spent once Spot instances have been successfully procured. \n",
146+
"2. Set the `max_wait constructor` arg - this is an int arg representing the amount of time you are willing to wait for Spot infrastructure to become available. Some instance types are harder to get at Spot prices and you may have to wait longer. You are not charged for time spent waiting for Spot infrastructure to become available, you're only charged for actual compute time spent once Spot instances have been successfully procured. \n",
147147
"\n",
148148
"3. Setup a `checkpoint_s3_uri` constructor arg - this arg will tell SageMaker an S3 location where to save checkpoints. While not strictly necessary, checkpointing is highly recommended for Manage Spot Training jobs due to the fact that Spot instances can be interrupted with short notice and using checkpoints to resume from the last interruption ensures you don't lose any progress made before the interruption.\n",
149149
"\n",
150-
"Feel free to toggle the `train_use_spot_instances` variable to see the effect of running the same job using regular (a.k.a. \"On Demand\") infrastructure.\n",
150+
"Feel free to toggle the `use_spot_instances` variable to see the effect of running the same job using regular (a.k.a. \"On Demand\") infrastructure.\n",
151151
"\n",
152-
"Note that `train_max_wait` can be set if and only if `train_use_spot_instances` is enabled and must be greater than or equal to `train_max_run`."
152+
"Note that `max_wait` can be set if and only if `use_spot_instances` is enabled and must be greater than or equal to `max_run`."
153153
]
154154
},
155155
{
@@ -163,27 +163,27 @@
163163
"job_name = 'DEMO-xgboost-spot-' + time.strftime(\"%Y-%m-%d-%H-%M-%S\", time.gmtime())\n",
164164
"print(\"Training job\", job_name)\n",
165165
"\n",
166-
"train_use_spot_instances = True\n",
167-
"train_max_run = 3600\n",
168-
"train_max_wait = 7200 if train_use_spot_instances else None\n",
169-
"checkpoint_s3_uri = ('s3://{}/{}/checkpoints/{}'.format(bucket, prefix, job_name) if train_use_spot_instances \n",
166+
"use_spot_instances = True\n",
167+
"max_run = 3600\n",
168+
"max_wait = 7200 if use_spot_instances else None\n",
169+
"checkpoint_s3_uri = ('s3://{}/{}/checkpoints/{}'.format(bucket, prefix, job_name) if use_spot_instances \n",
170170
" else None)\n",
171171
"print(\"Checkpoint path:\", checkpoint_s3_uri)\n",
172172
"\n",
173173
"estimator = sagemaker.estimator.Estimator(container, \n",
174174
" role, \n",
175175
" hyperparameters=hyperparameters,\n",
176-
" train_instance_count=1, \n",
177-
" train_instance_type=instance_type, \n",
178-
" train_volume_size=5, # 5 GB \n",
176+
" instance_count=1, \n",
177+
" instance_type=instance_type, \n",
178+
" volume_size=5, # 5 GB \n",
179179
" output_path=output_path, \n",
180180
" sagemaker_session=sagemaker.Session(),\n",
181-
" train_use_spot_instances=train_use_spot_instances, \n",
182-
" train_max_run=train_max_run, \n",
183-
" train_max_wait=train_max_wait,\n",
181+
" use_spot_instances=use_spot_instances, \n",
182+
" max_run=max_run, \n",
183+
" max_wait=max_wait,\n",
184184
" checkpoint_s3_uri=checkpoint_s3_uri\n",
185185
" );\n",
186-
"train_input = sagemaker.s3_input(s3_data='s3://{}/{}/{}'.format(bucket, prefix, 'train'), content_type='libsvm')\n",
186+
"train_input = sagemaker.TrainingInput(s3_data='s3://{}/{}/{}'.format(bucket, prefix, 'train'), content_type='libsvm')\n",
187187
"estimator.fit({'train': train_input}, job_name=job_name)"
188188
]
189189
},
@@ -197,7 +197,7 @@
197197
"- `Training seconds: X` : This is the actual compute-time your training job spent\n",
198198
"- `Billable seconds: Y` : This is the time you will be billed for after Spot discounting is applied.\n",
199199
"\n",
200-
"If you enabled the `train_use_spot_instances`, then you should see a notable difference between `X` and `Y` signifying the cost savings you will get for having chosen Managed Spot Training. This should be reflected in an additional line:\n",
200+
"If you enabled the `use_spot_instances`, then you should see a notable difference between `X` and `Y` signifying the cost savings you will get for having chosen Managed Spot Training. This should be reflected in an additional line:\n",
201201
"- `Managed Spot Training savings: (1-Y/X)*100 %`"
202202
]
203203
},
@@ -261,22 +261,22 @@
261261
"\n",
262262
"job_name = 'DEMO-xgboost-regression-' + time.strftime(\"%Y-%m-%d-%H-%M-%S\", time.gmtime())\n",
263263
"print(\"Training job\", job_name)\n",
264-
"checkpoint_s3_uri = ('s3://{}/{}/checkpoints/{}'.format(bucket, prefix, job_name) if train_use_spot_instances \n",
264+
"checkpoint_s3_uri = ('s3://{}/{}/checkpoints/{}'.format(bucket, prefix, job_name) if use_spot_instances \n",
265265
" else None)\n",
266266
"print(\"Checkpoint path:\", checkpoint_s3_uri)\n",
267267
"\n",
268268
"xgb_script_mode_estimator = XGBoost(\n",
269269
" entry_point=\"abalone.py\",\n",
270270
" hyperparameters=hyperparameters,\n",
271-
" image_name=container,\n",
271+
" image_uri=container,\n",
272272
" role=role, \n",
273-
" train_instance_count=1,\n",
274-
" train_instance_type=instance_type,\n",
273+
" instance_count=1,\n",
274+
" instance_type=instance_type,\n",
275275
" framework_version=\"0.90-1\",\n",
276276
" output_path=\"s3://{}/{}/{}/output\".format(bucket, prefix, \"xgboost-script-mode\"),\n",
277-
" train_use_spot_instances=train_use_spot_instances,\n",
278-
" train_max_run=train_max_run,\n",
279-
" train_max_wait=train_max_wait,\n",
277+
" use_spot_instances=use_spot_instances,\n",
278+
" max_run=max_run,\n",
279+
" max_wait=max_wait,\n",
280280
" checkpoint_s3_uri=checkpoint_s3_uri\n",
281281
")"
282282
]
@@ -296,6 +296,13 @@
296296
"source": [
297297
"xgb_script_mode_estimator.fit({'train': train_input, 'validation': train_input}, job_name=job_name)"
298298
]
299+
},
300+
{
301+
"cell_type": "code",
302+
"execution_count": null,
303+
"metadata": {},
304+
"outputs": [],
305+
"source": []
299306
}
300307
],
301308
"metadata": {
@@ -304,7 +311,7 @@
304311
"kernelspec": {
305312
"display_name": "Python 3 (Data Science)",
306313
"language": "python",
307-
"name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-west-2:236514542706:image/datascience-1.0"
314+
"name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-east-1:081325390199:image/datascience-1.0"
308315
},
309316
"language_info": {
310317
"codemirror_mode": {
@@ -321,4 +328,4 @@
321328
},
322329
"nbformat": 4,
323330
"nbformat_minor": 4
324-
}
331+
}

frameworks/mxnet/code/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../config.json

0 commit comments

Comments
 (0)