Skip to content

Commit 25913bc

Browse files
authored
Update Kmeans notebooks to match AWS docs updates from 11/24 (aws#51)
1 parent d1b0932 commit 25913bc

File tree

2 files changed

+16
-35
lines changed

2 files changed

+16
-35
lines changed

sagemaker-python-sdk/1P_kmeans_highlevel/kmeans_mnist.ipynb

+8-18
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,6 @@
5959
"bucket='<bucket-name>'"
6060
]
6161
},
62-
{
63-
"cell_type": "code",
64-
"execution_count": null,
65-
"metadata": {},
66-
"outputs": [],
67-
"source": [
68-
"data_key = 'kmeans_example/data'\n",
69-
"data_location = 's3://{}/{}'.format(bucket, data_key)\n",
70-
"output_location = 's3://{}/kmeans_example/output'.format(bucket)\n",
71-
"\n",
72-
"print('training data will be uploaded to: {}'.format(data_location))\n",
73-
"print('training artifacts will be uploaded to: {}'.format(output_location))"
74-
]
75-
},
7662
{
7763
"cell_type": "markdown",
7864
"metadata": {},
@@ -149,6 +135,12 @@
149135
"source": [
150136
"from sagemaker import KMeans\n",
151137
"\n",
138+
"data_location = 's3://{}/kmeans_highlevel_example/data'.format(bucket)\n",
139+
"output_location = 's3://{}/kmeans_example/output'.format(bucket)\n",
140+
"\n",
141+
"print('training data will be uploaded to: {}'.format(data_location))\n",
142+
"print('training artifacts will be uploaded to: {}'.format(output_location))\n",
143+
"\n",
152144
"kmeans = KMeans(role=role,\n",
153145
" train_instance_count=2,\n",
154146
" train_instance_type='ml.c4.8xlarge',\n",
@@ -281,10 +273,8 @@
281273
"metadata": {},
282274
"outputs": [],
283275
"source": [
284-
"# Uncomment and run to delete\n",
285-
"\n",
286-
"#import sagemaker\n",
287-
"#sagemaker.Session().delete_endpoint(kmeans_predictor.endpoint)"
276+
"import sagemaker\n",
277+
"sagemaker.Session().delete_endpoint(kmeans_predictor.endpoint)"
288278
]
289279
}
290280
],

sagemaker-python-sdk/1P_kmeans_lowlevel/kmeans_mnist_lowlevel.ipynb

+8-17
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,6 @@
5959
"bucket='<bucket-name>'"
6060
]
6161
},
62-
{
63-
"cell_type": "code",
64-
"execution_count": null,
65-
"metadata": {},
66-
"outputs": [],
67-
"source": [
68-
"data_key = 'kmeans_example/data'\n",
69-
"data_location = 's3://{}/{}'.format(bucket, data_key)\n",
70-
"output_location = 's3://{}/kmeans_example/output'.format(bucket)\n",
71-
"\n",
72-
"print('training data will be uploaded to: {}'.format(data_location))\n",
73-
"print('training artifacts will be uploaded to: {}'.format(output_location))"
74-
]
75-
},
7662
{
7763
"cell_type": "markdown",
7864
"metadata": {},
@@ -152,6 +138,10 @@
152138
"import io\n",
153139
"import boto3\n",
154140
"\n",
141+
"data_key = 'kmeans_lowlevel_example/data'\n",
142+
"data_location = 's3://{}/{}'.format(bucket, data_key)\n",
143+
"print('training data will be uploaded to: {}'.format(data_location))\n",
144+
"\n",
155145
"# Convert the training data into the format required by the SageMaker KMeans algorithm\n",
156146
"buf = io.BytesIO()\n",
157147
"write_numpy_to_dense_tensor(buf, train_set[0], train_set[1])\n",
@@ -190,6 +180,9 @@
190180
" 'eu-west-1': '438346466558.dkr.ecr.eu-west-1.amazonaws.com/kmeans:latest'}\n",
191181
"image = images[boto3.Session().region_name]\n",
192182
"\n",
183+
"output_location = 's3://{}/kmeans_example/output'.format(bucket)\n",
184+
"print('training artifacts will be uploaded to: {}'.format(output_location))\n",
185+
"\n",
193186
"create_training_params = \\\n",
194187
"{\n",
195188
" \"AlgorithmSpecification\": {\n",
@@ -473,9 +466,7 @@
473466
"metadata": {},
474467
"outputs": [],
475468
"source": [
476-
"# Uncomment and run to delete\n",
477-
"\n",
478-
"# sagemaker.delete_endpoint(EndpointName=endpoint_name)"
469+
"sagemaker.delete_endpoint(EndpointName=endpoint_name)"
479470
]
480471
}
481472
],

0 commit comments

Comments
 (0)