Main Content

Deep Network Designer

Design, visualize, and train deep learning networks

Description

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

  • Build, edit, and combine networks.

  • Load pretrained networks and edit them for transfer learning.

  • Import networks from PyTorch® and TensorFlow™.

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

  • Import and visualize datastores 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.

  • Export trained networks to the workspace or to Simulink®.

  • Generate MATLAB® code for building and training networks and create experiments for hyperparameter tuning using Experiment Manager.

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 pretrained 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. Deep Network Designer has pretrained networks suitable for image and audio tasks. Loading pretrained audio networks requires Audio Toolbox™.

Tip

To get started, try choosing one of the faster image classification 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.

Deep Network Designer start page showing available networks

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

Deep Network Designer displaying a pretrained image classification network

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, edit the last learnable layer and the final classification layer. For SqueezeNet, the last learnable layer is a 2-D convolutional layer named 'conv10'.

  • Select the 'conv10' layer. At the bottom of the Properties pane, click Unlock Layer. Unlocking the layer will delete all of the layer learnables. In the warning dialog that appears, click Unlock Anyway. This unlocks the layer properties so that you can adapt them to your new task. Set 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 values.

Convolution 2-D layer selected in Deep Network Designer. The Properties pane shows NumFilters set to 5.

Tip

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

Before R2023b: To edit the layer properties for a new task, you must replace the layers instead of unlocking them.

Next, edit the classification output layer. In the Properties pane, click Unlock Layer and then click Unlock Anyway. The default settings for the output layer mean the network learns the number of classes during training.

Classification layer selected in Deep Network Designer. The Properties pane shows OutputSize set to auto.

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.

Import a neural network from PyTorch or TensorFlow.

To import a network from an external platform, use the Deep Network Designer Start Page.

  • For PyTorch, click Import on the From PyTorch icon. In the Import Network dialog box, select the location of the model file.

  • For TensorFlow, click Import on the From TensorFlow icon. In the Import Network dialog box, select the location of the model folder.

Once you select the location of the network, click Import.

The Deep Network Designer app imports the network and generates an Import Report. The Import Report displays any issues with the network that require attention before you use the network for training or inference. For example, the report shows a warning if the app is unable to infer the input sizes or if there are any placeholder layers that you need to complete.

Example of an import report. The report displays a warning about the input layer and an error about placeholder layers.

Data import and training in the app is not supported for networks imported from PyTorch or TensorFlow.

For an example that shows how to import a PyTorch network into Deep Network Designer and fix any issues, see Import PyTorch® Model Using 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.

Cross channel normalization layer selected in Deep Network Designer

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 build a network with a custom layer 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.

To view or edit the custom layer class definition, select the layer, and then click Edit Layer Code. For more information, see View Autogenerated Custom Layers Using Deep Network Designer. (since R2023a)

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 Classification Data.

Import Image Data dialog box

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.

Data tab of Deep Network Designer displaying a histogram of the class labels and a selection of random images from the imported data

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), audioDatastore (Audio 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 Custom Data.

Import Datastore dialog box

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

Data tab of Deep Network Designer displaying a preview of the first five observations in the datastore

Train deep neural networks using Deep Network Designer.

Using Deep Network Designer, you can train a network using image data or any datastore object that works with the trainNetwork function. For example, you can train a semantic segmentation network or a multi-input network using a CombinedDatastore object. For more information about importing data into Deep Network Designer, see Import Data into Deep Network Designer.

To train a network on data imported into Deep Network Designer, on the Training tab, click Train. The app displays an animated plot of the training progress. The plot shows mini-batch loss and accuracy, validation loss and accuracy, and additional information on the training progress. The plot has a stop button in the top-right corner. Click the button to stop training and return the current state of the network.

Training progress plot in Deep Network Designer

For more information, see Train Networks Using Deep Network Designer.

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.

Training Options dialog box in Deep Network Designer

For an example showing how to train an image classification network, see Transfer Learning with Deep Network Designer. For an example showing how to train a sequence-to-sequence LSTM network, see Train Network for Time Series Forecasting Using Deep Network Designer.

To train a network on data not supported by Deep Network Designer, select the Designer tab, and click Export to export the initial network architecture. You can then programmatically train the network, for example, using a custom training loop.

Export the network architecture created in Deep Network Designer to the workspace or Simulink and generate code to recreate the network and training.

  • To export the network architecture with the initial weights to the workspace, 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 trained in Deep Network Designer to the workspace, 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 export the network trained in Deep Network Designer to Simulink, on the Training tab, click Export > Export to Simulink. Deep Network Designer saves the trained network as a MAT-file and generates Simulink blocks representing the trained network. The blocks generated depend on the type of network trained.

    • Image Classifier — Classify data using a trained deep learning neural network.

    • Predict — Predict responses using a trained deep learning neural network.

    • Stateful Classify — Classify data using a trained recurrent neural network.

    • Stateful Predict — Predict responses using a trained recurrent neural network.

For an example showing how to export a network from Deep Network Designer to Simulink, see Export Image Classification Network from Deep Network Designer to Simulink.

To recreate a network that you construct and train in Deep Network Designer, generate MATLAB code.

  • To recreate the network layers, including any learnable parameters, on the Designer tab, select Export > Generate Network Code With Parameters.

  • To recreate just the network layers, on the Designer tab, select Export > Generate Network Code Without Parameters.

  • 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 created in the app, run the script. If you generated the training script, running the script will also replicate the network training.

  • Examine the code to learn how to create and connect layers programmatically, and how to train a deep network.

  • 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 from Deep Network Designer.

You can also use Deep Network Designer to create deep learning experiments which sweep through a range of hyperparameter values or use Bayesian optimization to find optimal training options. For an example showing how to use Experiment Manager to tune the hyperparameters of a network trained in Deep Network Designer, see Generate Experiment Using 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, array of layers, or dlnetwork object. Data import and training in the app is not supported for dlnetwork objects.

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. You can use Deep Network Designer to create experiments suitable for Experiment Manager.

Version History

Introduced in R2018b