Deep Network Designer
Design, visualize, and train deep learning networks
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.
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.
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
Select Pretrained Network
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™.
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.
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.
For information on constructing networks using Deep Network Designer, see Build Networks with Deep Network Designer.
Edit Pretrained Network for Transfer Learning
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.
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
Drag a new convolution2dLayer onto the canvas. Set the FilterSize property to
1,1and 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.
Delete the last convolution2dLayer and connect your new layer instead.
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.
Get Help on Layer Properties
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 Custom Layer to Network
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
Click New in the Designer tab.
Pause on From Workspace and click Import.
myCustomLayerand click OK.
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.
Import Data for Training
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.
|Task||Data Type||Data Import Method||Example Visualization|
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)|
For other extended workflows, use a suitable
datastore object. For example,
You can import
and train any datastore object that works with the
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.
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.
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
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 Network and Generate Code
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
LayerGraphlgraph or as a
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
DAGNetworkobject 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.
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.
To recreate the network layers, including any learnable parameters, on the Designer tab, select Export > Generate Code with Initial 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.
- Transfer Learning with Deep Network Designer
- Build Networks with Deep Network Designer
- Import Data into Deep Network Designer
- Train Networks Using Deep Network Designer
- Train Network for Time Series Forecasting Using Deep Network Designer
- Train Simple Semantic Segmentation Network in Deep Network Designer
- Image-to-Image Regression in Deep Network Designer
- Transfer Learning with Pretrained Audio Networks in Deep Network Designer
- Import Custom Layer into Deep Network Designer
- Generate MATLAB Code from Deep Network Designer
- Generate Experiment Using Deep Network Designer
- List of Deep Learning Layers
deepNetworkDesigner opens the Deep Network Designer app. If Deep
Network Designer is already open,
deepNetworkDesigner brings focus to the
deepNetworkDesigner( 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,
brings focus to the app and prompts you to add to or replace any existing network.
To train multiple networks and compare the results, try Experiment Manager. You can use Deep Network Designer to create experiments suitable for Experiment Manager.