Skip to content

Commit

Permalink
Update Kmeans notebooks to match AWS docs updates from 11/24 (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
winstonaws authored Nov 25, 2017
1 parent d1b0932 commit 25913bc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 35 deletions.
26 changes: 8 additions & 18 deletions sagemaker-python-sdk/1P_kmeans_highlevel/kmeans_mnist.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,6 @@
"bucket='<bucket-name>'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"data_key = 'kmeans_example/data'\n",
"data_location = 's3://{}/{}'.format(bucket, data_key)\n",
"output_location = 's3://{}/kmeans_example/output'.format(bucket)\n",
"\n",
"print('training data will be uploaded to: {}'.format(data_location))\n",
"print('training artifacts will be uploaded to: {}'.format(output_location))"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -149,6 +135,12 @@
"source": [
"from sagemaker import KMeans\n",
"\n",
"data_location = 's3://{}/kmeans_highlevel_example/data'.format(bucket)\n",
"output_location = 's3://{}/kmeans_example/output'.format(bucket)\n",
"\n",
"print('training data will be uploaded to: {}'.format(data_location))\n",
"print('training artifacts will be uploaded to: {}'.format(output_location))\n",
"\n",
"kmeans = KMeans(role=role,\n",
" train_instance_count=2,\n",
" train_instance_type='ml.c4.8xlarge',\n",
Expand Down Expand Up @@ -281,10 +273,8 @@
"metadata": {},
"outputs": [],
"source": [
"# Uncomment and run to delete\n",
"\n",
"#import sagemaker\n",
"#sagemaker.Session().delete_endpoint(kmeans_predictor.endpoint)"
"import sagemaker\n",
"sagemaker.Session().delete_endpoint(kmeans_predictor.endpoint)"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,6 @@
"bucket='<bucket-name>'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"data_key = 'kmeans_example/data'\n",
"data_location = 's3://{}/{}'.format(bucket, data_key)\n",
"output_location = 's3://{}/kmeans_example/output'.format(bucket)\n",
"\n",
"print('training data will be uploaded to: {}'.format(data_location))\n",
"print('training artifacts will be uploaded to: {}'.format(output_location))"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -152,6 +138,10 @@
"import io\n",
"import boto3\n",
"\n",
"data_key = 'kmeans_lowlevel_example/data'\n",
"data_location = 's3://{}/{}'.format(bucket, data_key)\n",
"print('training data will be uploaded to: {}'.format(data_location))\n",
"\n",
"# Convert the training data into the format required by the SageMaker KMeans algorithm\n",
"buf = io.BytesIO()\n",
"write_numpy_to_dense_tensor(buf, train_set[0], train_set[1])\n",
Expand Down Expand Up @@ -190,6 +180,9 @@
" 'eu-west-1': '438346466558.dkr.ecr.eu-west-1.amazonaws.com/kmeans:latest'}\n",
"image = images[boto3.Session().region_name]\n",
"\n",
"output_location = 's3://{}/kmeans_example/output'.format(bucket)\n",
"print('training artifacts will be uploaded to: {}'.format(output_location))\n",
"\n",
"create_training_params = \\\n",
"{\n",
" \"AlgorithmSpecification\": {\n",
Expand Down Expand Up @@ -473,9 +466,7 @@
"metadata": {},
"outputs": [],
"source": [
"# Uncomment and run to delete\n",
"\n",
"# sagemaker.delete_endpoint(EndpointName=endpoint_name)"
"sagemaker.delete_endpoint(EndpointName=endpoint_name)"
]
}
],
Expand Down

0 comments on commit 25913bc

Please sign in to comment.