TensorFlow is the biggest name in machine learning frameworks. In this lab, you will use TensorFlow 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.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- 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.
- Load and Prepare the Data
- Load the training images and labels into numpy arrays. The images and labels are provided in the files
lego-simple-train-images.npy
andlego-simple-train-labels.npy
, respectively. - Load the testing images and labels into numpy arrays. The images and labels are provided in the files
lego-simple-test-images.npy
andlego-simple-test-labels.npy
, respectively. - Add in the human-readable class names for the labels.
- Visualize the first few images from the training data set to better understand the data.
- Load the training images and labels into numpy arrays. The images and labels are provided in the files
- Train the TensorFlow Model
- Create a neural network model using Keras.
- 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 probabilites.
- Compile the model, including accuracy as a metric. Your loss function should be one 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 Keras.
- Evaluate the Model
- Calculate the loss and 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.
- Make a Batch Prediction
- Predict the labels for all of the testing data.
- Compare the predictions against the actual labels.