- Lab
- A Cloud Guru
Creating an MXNet Image Classifier in Amazon SageMaker
Apache MXNet is an open-source machine learning framework focusing on deep learning with neural networks. In this lab, you will use MXNet to create a neural network that performs a basic image classification task: deciding which LEGO brick is in an image to help you sort your giant pile of blocks. MXNet supports many programming languages, but we will use Python.
Path Info
Table of Contents
-
Challenge
Navigate to the Jupyter Notebook
Log in to the AWS console and navigate to the AWS SageMaker page. From there, load the Jupyter Notebook that has been provided with this hands-on lab.
When prompted, select the conda_python3 kernel. In the notebook, the code line of
%pip install mxnet
installs the neededmxnet
package. -
Challenge
Load and Prepare the Data
- Load the training images and labels into an NDArray using Pickle. The images and labels are provided in the
lego-simple-mx-train
file. - Load the testing images and labels into an NDArray using Pickle. The images and labels are provided in the
lego-simple-mx-test
file. - Add in the human-readable class names for the labels.
- Convert the training and testing NDArrays to MXNet Tensors. For better results, normalize the data using the mean of 0.13 and standard deviation of 0.31, which have been precomputed for this dataset.
- Visualize the first few images from the training data set to better understand the data.
- Load the training images and labels into an NDArray using Pickle. The images and labels are provided in the
-
Challenge
Train the MXNet Model
- Create a neural network model using Gluon.
- Remember to check your input shape and adjust if necessary.
- You can get decent performance from a single hidden layer, but feel free to experiment with different model architectures.
- You should have as many output nodes as labels you are trying to predict. Remember to pick an activation function that will output categorical probabilities.
- Keep track of accuracy during your training process.
- Choose a loss function appropriate for classification tasks.
- Train the model using the training data and training labels. You won't need to train for many epochs. Save the history of the training process.
- Create a neural network model using Gluon.
-
Challenge
Evaluate the Model
- Calculate the accuracy of the model on the testing data.
- View the raw output of a model prediction for an image in the test set.
- Determine the label that the model predicted for the image and compare that to the actual label.
-
Challenge
Make a Batch Prediction
- Predict the labels for all of the testing data.
- Compare the predictions against the actual labels.
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.