Main Content

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:

  • Build, import, edit, and combine networks.

  • Load pretrained networks and edit them for transfer learning.

  • View and edit layer properties and add new layers and connections.

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

  • Import and visualize datastores and image data for training and validation.

  • Apply augmentations to image classification training data and visualize the distribution of the class labels.

  • Train networks and monitor training with plots of accuracy, loss, and validation metrics.

  • Generate MATLAB® code for building and training networks.

Deep Network Designer app

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 image classification network in Deep Network Designer.

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 to open the Add-On Explorer.

Tip

To get started, try choosing one of the faster networks, such as SqueezeNet or GoogLeNet. Once you gain an understanding 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 pretrained 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.

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

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 with SqueezeNet.

deepNetworkDesigner(squeezenet)

To prepare the network for transfer learning, replace the last learnable layer and the final classification layer. For SqueezeNet, the last learnable layer is a 2-D convolutional layer named 'conv10'.

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

  • Change the learning rates so that learning is faster in the new layer than in the transferred layers by increasing the WeightLearnRateFactor and BiasLearnRateFactor.

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

Tip

For most pretrained networks (for example, GoogLeNet) the last learnable layer is the fully connected layer. To prepare the network for transfer learning, replace the fully connected layer with a new fully connected layer and set the OutputSize property to the new number of classes. For an example, see Get Started with Deep Network Designer.

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 the network learns the number of classes during training.

Check your network by clicking Analyze in the Designer tab. The network is ready for training if Deep Learning Network Analyzer reports zero errors. For an example showing how to train a network to classify new images, 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.

Add layers from the workspace to a network in Deep Network Designer.

In Deep Network Designer, you can build a network by dragging built-in layers from the Layer Library to the Designer pane and connecting them. You can also add custom layers from the workspace to a network in the Designer pane. Suppose that you have a custom layer stored in the variable myCustomLayer.

  1. Click New in the Designer tab.

  2. Pause on From Workspace and click Import.

  3. Select myCustomLayer and click OK.

  4. Click Add.

The app adds the custom layer to the top of the Designer pane. To see the new layer, zoom-in using a mouse or click Zoom in.

Connect myCustomLayer to the network in the Designer pane. For an example showing how to use a custom output layer to build a weighted classification network in Deep Network Designer, see Import Custom Layer into Deep Network Designer.

You can also combine networks in Deep Network Designer. For example, you can create a semantic segmentation network by combining a pretrained network with a decoder subnetwork.

Import data into Deep Network Designer for training.

You can use the Data tab of Deep Network Designer to import training and validation data. Deep Network Designer supports the import of image data and datastore objects. Select an import method based on the type of task.

TaskData TypeData Import MethodExample Visualization
Image classification

ImageDatastore object, or a folder with subfolders containing images for each class. The class labels are sourced from the subfolder names.

Select Import Data > Import Image Data.

You can select augmentation options and specify the validation data in the Import Image Data dialog box. For more information, see Import Data into Deep Network Designer.

Other extended workflows (such as numeric feature input, out-of-memory data, image processing, and audio and speech processing)

Datastore.

For other extended workflows, use a suitable datastore object. For example, AugmentedImageDatastore, CombinedDatastore, pixelLabelImageDatastore (Computer Vision Toolbox), or custom datastore.

You can import and train any datastore object that works with the trainNetwork function. For more information about constructing and using datastore objects for deep learning applications, see Datastores for Deep Learning.

Select Import Data > Import Datastore.

You can specify the validation data in the Import Datastore dialog box. For more information, see Import Data into Deep Network Designer.

To train a network on data you import 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.

Create and 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. Depending on the network architecture, Deep Network Designer exports the network as a LayerGraph lgraph or as a Layer object layers.

  • To export the network architecture with the trained weights, on the Training tab, click Export. Deep Network Designer exports the trained network architecture as a DAGNetwork object trainedNetwork. Deep Network Designer also exports the results from training, such as training and validation accuracy, as the structure array trainInfoStruct.

To recreate a network that you construct and train in Deep Network Designer, 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.

To recreate the network, 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 import data programmatically, 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 from Deep Network Designer.

Related Examples

Programmatic Use

expand all

deepNetworkDesigner opens the Deep Network Designer app. If Deep Network Designer is already open, deepNetworkDesigner brings focus to the app.

deepNetworkDesigner(net) opens the Deep Network Designer app and loads the specified network into the app. The network can be a series network, DAG network, layer graph, or an array of layers.

For example, open Deep Network Designer with a pretrained SqueezeNet network.

net = squeezenet;
deepNetworkDesigner(net);

If Deep Network Designer is already open, deepNetworkDesigner(net) brings focus to the app and prompts you to add to or replace any existing network.

Tips

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

Introduced in R2018b