Image Recognition Code-Along

Learn how to load and preprocess data, import a network, transfer learning, and test the network for deep learning with images.

To follow along:

  1. Download the code
  2. Open in MATLAB

Don’t have access? Get a free trial now.

Time to Complete:
15–30 minutes
Prerequisites:
Basic MATLAB skills

Need a refresher? Try a free, interactive tutorial.

Step 1

Load and Preprocess Data

Import, manage, and store data for your deep learning projects with images.

 

What you learned: To import and prepare data for training

  • Load data as an image datastore
  • The imageDatastore function automatically labels the images based on folder names
  • Preprocessing data is a common first step in the deep learning workflow to prepare raw data in a format that the network can accept

Step 2

Import Network

Ensure the imported network and the image data are the right size to produce a highly accurate model. 

 

What you learned: To use the network for model predictions before retraining

  • Import networks and network architectures from TensorFlow-Keras, TensorFlow 2, Caffe, and the ONNX (Open Neural Network Exchange) model format
  • Export a trained Deep Learning Toolbox network to the ONNX model format

Step 3

Transfer Learning​

Modify an existing network to work with your data, so you can customize deep learning to perform your specific task.

 

What you learned: To prepare the model for a new task

  • Transfer the learned features of a pretrained network to a new problem
  • Transfer learning is faster and easier than training a new network
  • Reduce training time and dataset size
  • Perform deep learning without needing to learn how to create a whole new network

Step 4

Test the Network​​​

Verify how well the model works with new data and not just the data it learned during training.

 

What you learned: To test all images in the validation set and evaluate how well the network trained

  • Classify the validation data and calculate the classification accuracy
  • Try using pretrained network for other tasks
  • Solve new classification problems on your image data with transfer learning or feature extraction