Skip to content

Commit 5d0a376

Browse files
authored
Revise MXNet MNIST markdown (#3319)
1 parent 7898806 commit 5d0a376

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

sagemaker-python-sdk/mxnet_gluon_mnist/mxnet_mnist_with_gluon.ipynb

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,19 @@
66
"source": [
77
"# MNIST Training with MXNet and Gluon\n",
88
"\n",
9-
"MNIST is a widely used dataset for handwritten digit classification. It consists of 70,000 labeled 28x28 pixel grayscale images of hand-written digits. The dataset is split into 60,000 training images and 10,000 test images. There are 10 classes (one for each of the 10 digits). This tutorial will show how to train and test an MNIST model on SageMaker using MXNet and the Gluon API.\n",
10-
"\n"
9+
"MNIST is a widely used dataset for handwritten digit classification. It consists of 70,000 labeled 28x28 pixel grayscale images of hand-written digits. The dataset is split into 60,000 training images and 10,000 test images. There are 10 classes (one for each of the 10 digits). This tutorial shows how to train and test an MNIST model on SageMaker using MXNet and the Gluon API.\n",
10+
"\n",
11+
"## Runtime\n",
12+
"\n",
13+
"This notebook takes approximately 20 minutes to run.\n",
14+
"\n",
15+
"## Contents\n",
16+
"\n",
17+
"1. [Download training and test data](#Download-training-and-test-data)\n",
18+
"1. [Upload the data](#Upload-the-data)\n",
19+
"1. [Implement the training function](#Implement-the-training-function)\n",
20+
"1. [Run the training script on SageMaker](#Run-the-training-script-on-SageMaker)\n",
21+
"1. [Cleanup](#Cleanup)\n"
1122
]
1223
},
1324
{
@@ -75,9 +86,9 @@
7586
"cell_type": "markdown",
7687
"metadata": {},
7788
"source": [
78-
"## Uploading the data\n",
89+
"## Upload the data\n",
7990
"\n",
80-
"We use the `sagemaker.Session.upload_data` function to upload our datasets to an S3 location. The return value `inputs` identifies the location -- we will use this later when we start the training job."
91+
"We use the `sagemaker.Session.upload_data` function to upload our datasets to an S3 location. The return value `inputs` identifies the location -- we use this later when we start the training job."
8192
]
8293
},
8394
{
@@ -95,9 +106,9 @@
95106
"source": [
96107
"## Implement the training function\n",
97108
"\n",
98-
"We need to provide a training script that can run on the SageMaker platform. The training scripts are essentially the same as one you would write for local training, except that you need to provide a `train` function. The `train` function will check for the validation accuracy at the end of every epoch and checkpoints the best model so far, along with the optimizer state, in the folder `/opt/ml/checkpoints` if the folder path exists, else it will skip the checkpointing. When SageMaker calls your function, it will pass in arguments that describe the training environment. Check the script below to see how this works.\n",
109+
"We need to provide a training script that can run on the SageMaker platform. The training scripts are essentially the same as one you would write for local training, except that you need to provide a `train()` function. The `train()` function checks for the validation accuracy at the end of every epoch and checkpoints the best model so far, along with the optimizer state, in the folder `/opt/ml/checkpoints` if the folder path exists, else it skips the checkpointing. When SageMaker calls your function, it passes in arguments that describe the training environment. Check the script below to see how this works.\n",
99110
"\n",
100-
"The script here is an adaptation of the [Gluon MNIST example](https://github.com/apache/incubator-mxnet/blob/master/example/gluon/mnist.py) provided by the [Apache MXNet](https://mxnet.incubator.apache.org/) project. "
111+
"The script here is an adaptation of the [Gluon MNIST example](https://github.com/apache/incubator-mxnet/blob/master/example/gluon/mnist/mnist.py) provided by the [Apache MXNet](https://mxnet.incubator.apache.org/) project."
101112
]
102113
},
103114
{
@@ -115,7 +126,7 @@
115126
"source": [
116127
"## Run the training script on SageMaker\n",
117128
"\n",
118-
"The ```MXNet``` class allows us to run our training function on SageMaker infrastructure. We need to configure it with our training script, an IAM role, the number of training instances, and the training instance type. In this case we will run our training job on a single c4.xlarge instance. "
129+
"The ```MXNet``` class allows us to run our training function on SageMaker infrastructure. We need to configure it with our training script, an IAM role, the number of training instances, and the training instance type. In this case we run our training job on a single c4.xlarge instance."
119130
]
120131
},
121132
{
@@ -145,7 +156,7 @@
145156
"cell_type": "markdown",
146157
"metadata": {},
147158
"source": [
148-
"After we've constructed our `MXNet` object, we can fit it using the data we uploaded to S3. SageMaker makes sure our data is available in the local filesystem, so our training script can simply read the data from disk.\n"
159+
"After we've constructed our `MXNet` object, we fit it using the data we uploaded to S3. SageMaker makes sure our data is available in the local filesystem, so our training script can simply read the data from disk.\n"
149160
]
150161
},
151162
{
@@ -163,9 +174,9 @@
163174
"cell_type": "markdown",
164175
"metadata": {},
165176
"source": [
166-
"After training, we use the MXNet object to build and deploy an MXNetPredictor object. This creates a SageMaker endpoint that we can use to perform inference. \n",
177+
"After training, we use the MXNet object to build and deploy an MXNetPredictor object. This creates a SageMaker endpoint that we use to perform inference.\n",
167178
"\n",
168-
"This allows us to perform inference on json encoded multi-dimensional arrays. "
179+
"This allows us to perform inference on JSON-encoded multi-dimensional arrays."
169180
]
170181
},
171182
{
@@ -183,7 +194,7 @@
183194
"cell_type": "markdown",
184195
"metadata": {},
185196
"source": [
186-
"We can now use this predictor to classify hand-written digits. Manually drawing into the image box loads the pixel data into a 'data' variable in this notebook, which we can then pass to the MXNet predictor. "
197+
"We can now use this predictor to classify hand-written digits. Manually drawing into the image box loads the pixel data into a 'data' variable in this notebook, which we can then pass to the MXNet predictor."
187198
]
188199
},
189200
{
@@ -253,7 +264,7 @@
253264
"source": [
254265
"## Cleanup\n",
255266
"\n",
256-
"After you have finished with this example, remember to delete the prediction endpoint to release the instance(s) associated with it."
267+
"After you have finished with this example, delete the prediction endpoint to release the instance associated with it."
257268
]
258269
},
259270
{

0 commit comments

Comments
 (0)