Deep Network Designer

Design, visualize, and train deep learning networks

Description

The Deep Network Designer app lets you build, visualize, edit, and train deep learning networks. Using this app, you can:

  • Load pretrained networks and edit them for transfer learning.

  • Import and edit networks and build new networks.

  • Drag and drop to add new layers and create new connections.

  • View and edit layer properties.

  • Analyze the network to ensure that the network architecture is defined correctly, and detect problems before training.

  • Import image data for classification problems, and select augmentation options.

  • Train networks for image classification tasks.

  • Monitor training with plots of accuracy, loss, and validation metrics.

  • Generate MATLAB® code for building and training networks.

After you finish designing a network, you can export it to the workspace, where you can save or train the network. For image classification problems, you can also train the network using Deep Network Designer. You can export the trained network and the results to the workspace.

Open the Deep Network Designer App

  • MATLAB Toolstrip: On the Apps tab, under Machine Learning and Deep Learning, click the app icon.

  • MATLAB command prompt: Enter deepNetworkDesigner.

Examples

expand all

Examine a simple pretrained network in the Deep Network Designer app.

Open the app and select a pretrained network. You can also load a pretrained network by selecting the Designer tab and clicking New. If you need to download the network, then click Install for a link to Add-On Explorer.

Tip

To get started, try choosing one of the faster networks, such as SqueezeNet or GoogLeNet. Once you have a feeling of which settings work well, try a more accurate network, such as Inception-v3 or a ResNet, and see if that improves your results. For more information on selecting a pretrained network, see Pretrained Deep Neural Networks.

In the Designer pane, visualize and explore the network. For a list of available networks and how to compare them, see Pretrained Deep Neural Networks.

For information on constructing networks using Deep Network Designer, see Build Networks with Deep Network Designer.

Import image data into Deep Network Designer for training.

To import data into the app, on the Data tab, click Import Data.

You can import data from a folder with subfolders of images for each class, or from an imageDatastore in the workspace.

Deep Network Designer provides a selection of image augmentation options. You can effectively increase the amount of training data by applying randomized augmentation to your data. If you choose to augment your data, Deep Network Designer randomly perturbs the training data for each epoch. Each epoch then uses a slightly different data set.

Deep Network Designer provides the following augmentation options:

  • Random reflection in the x-axis

  • Random reflection in the y-axis

  • Random rotation

  • Random rescaling

  • Random horizontal translation

  • Random vertical translation

Note

As some augmentations are inappropriate for particular data sets, by default, Deep Network Designer does not augment the data. For more information, see Augment Images for Training with Random Geometric Transformations.

Import validation data by selecting a folder, or importing an imageDatastore from the workspace. You can also choose to split the validation data from the training data. Validation data can help you to monitor performance and protect against overfitting.

After you select the location of the training data, specify the validation data, and set any augmentation options, click Import to import the data set.

Prepare a network for transfer learning by editing it in the Deep Network Designer app.

Transfer learning is the process of taking a pretrained deep learning network and fine-tuning it to learn a new task. You can quickly transfer learned features to a new task using a smaller number of training images. Transfer learning is therefore often faster and easier than training a network from scratch. To use a pretrained network for transfer learning, you must change the number of classes to match your new data set.

Open Deep Network Designer.

deepNetworkDesigner

Load a pretrained network by selecting it from the Deep Network Designer start page. Try selecting SqueezeNet from the list of pretrained networks. Click Open to load the network.

To prepare the network for transfer learning, replace the last learnable layer and the final classification layer.

  • If the last learnable layer is a 2-D convolutional layer (for example, the 'conv10' layer in SqueezeNet):

    • Drag a new convolutional2dLayer onto the canvas. Set the NumFilters property to the new number of classes and FilterSize to 1,1.

    • Delete the last convolutional2dLayer and connect your new layer instead.

  • If the last learnable layer is a fully connected layer (most pretrained networks, for example, GoogLeNet):

    • Drag a new fullyConnectedLayer onto the canvas and set the OutputSize property to the new number of classes.

    • Delete the last fullyConnectedLayer and connect your new layer instead.

Next, delete the classification output layer. Then, drag a new classificationLayer onto the canvas and connect it instead. The default settings for the output layer mean it will learn the number of classes during training.

To check that the network is ready for training, on the Designer tab, click Analyze.

To train the network, select the Training tab. For more information, see Transfer Learning with Deep Network Designer.

For help understanding and editing layer properties, click the help icon next to the layer name.

On the Designer pane, select a layer to view and edit the properties. Click the help icon next to the layer name for more information about the properties of the layer.

For more information about layer properties, see List of Deep Learning Layers.

Train an image classification network in the Deep Network Designer app.

To train a network on image data imported into Deep Network Designer, on the Training tab, click Train. If you require greater control over the training, click Training Options to select the training settings. For more information about selecting training options, see trainingOptions.

For an example showing how to train an image classification network, see Transfer Learning with Deep Network Designer.

To train a network on other types of data, select the Designer tab and click Export to export the initial network architecture. You can then programmatically train the network. For a simple example, see Create Simple Sequence Classification Network Using Deep Network Designer.

Export the network architecture, created in Deep Network Designer, to the workspace.

  • To export the network architecture with the initial weights, on the Designer tab, click Export.

  • To export the network architecture with the trained weights, on the Training tab, click Export.

To recreate the network layers you create in the Deep Network Designer app, generate MATLAB code.

To recreate the network layers, on the Designer tab, select Export > Generate Code.

Alternatively, you can recreate your network, including any learnable parameters, by selecting Export > Generate Code with Initial Parameters.

After generating a script you can perform the following tasks.

  • To recreate the network layers created in the app, run the script.

  • To train the network, run the script and then supply the layers to the trainNetwork function.

  • Examine the code to learn how to create and connect layers programmatically.

  • To modify the layers, edit the code. You can also run the script and import the network back into the app for editing.

For more information, see Generate MATLAB Code to Recreate Network Layers.

To recreate the data import and training you perform in the Deep Network Designer app, generate MATLAB code.

To recreate the data import and training, on the Training tab, select Export > Generate Code for Training.

After generating a script you can perform the following tasks.

  • To recreate the network layers and the training performed in the app, run the script.

  • Examine the code to learn how to programmatically import data, and construct and train a network.

  • Modify the code to try different network architectures and training options, and see how they affect the results.

For more information, see Generate MATLAB Code to Train Network.

Related Examples

Tips

To train multiple networks and compare the results, try Experiment Manager.

Introduced in R2018b