Main Content

Build Networks with Deep Network Designer

Build and edit deep learning networks interactively using the Deep Network Designer app. Using this app, you can import networks or build a network from scratch, view and edit layer properties, combine networks, and generate code to create the network architecture.

You can use Deep Network Designer for a range of network construction tasks:

Assemble a network by dragging blocks from the Layer Library and connecting them. To quickly search for layers, use the Filter layers search box in the Layer Library pane.

Designer pane of Deep Network Designer with an imageInputLayer connected to a convolution2dLayer and an unconnected reluLayer

You can add layers from the workspace to the network in the Designer pane.

  1. Click New.

  2. Pause on From Workspace and click Import.

  3. Choose the layers or network to import and click OK.

  4. Click Add to add the layers or network to the Designer pane.

You can also load pretrained networks by clicking New and selecting them from the start page.

To view and edit layer properties, select a layer. Click the help icon next to the layer name for information on the layer properties.

Properties pane displaying the properties of a crossChannelNormalizationLayer

For information on all layer properties, click the layer name in the table on the List of Deep Learning Layers page.

Once you have constructed your network, you can analyze it to check for errors. For more information, see Check Network.

Transfer Learning

Transfer learning is commonly used in deep learning applications. You can take a pretrained network and use it as a starting point to learn a new task. Fine-tuning a network with transfer learning is usually much faster and easier than training a network with randomly initialized weights from scratch. You can quickly transfer learned features to a new task using a smaller number of training images.

Deep Network Designer has a selection of pretrained networks suitable for transfer learning with image data.

Load Pretrained Network

Open the app and select a pretrained network. You can also load a pretrained network by clicking New. If you need to download the network, pause on the network and 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.

Deep Network Designer start page showing available networks

Adapt Pretrained Network

To prepare the network for transfer learning, edit the last learnable layer.

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

    • Select the convolutional layer. At the bottom of the Properties pane, click Unlock Layer. 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.

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

    • Select the fully connected layer. At the bottom of the Properties pane, click Unlock Layer. This unlocks the layer properties so that you can adapt them to your new task. Set the OutputSize 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.

Fully connected layer selected in Deep Network Designer. The Properties pane shows OutputSize set to 5.

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

For an example showing how to retrain a pretrained network to classify new images, see Prepare Network for Transfer Learning Using Deep Network Designer. If you have Audio Toolbox™, you can also load pretrained networks suitable for audio tasks. For an example showing how to retrain a pretrained network to classify a new set of audio signals, see Adapt Pretrained Audio Network for New Data Using Deep Network Designer.

You can also use the app to import networks from external platforms. For more information, see Import PyTorch® Model Using Deep Network Designer.

Image Classification

You can build an image classification network using Deep Network Designer by dragging layers from the Layer Library and connecting them. You can also create the network at the command line and then import the network into Deep Network Designer.

For example, create a network to train for image classification on a data set of 28-by-28 images divided into 10 classes.

inputSize = [28 28 1];
numClasses = 10;

layers = [
    imageInputLayer(inputSize)
    convolution2dLayer(5,20)
    batchNormalizationLayer
    reluLayer
    fullyConnectedLayer(numClasses)
    softmaxLayer];

deepNetworkDesigner(layers)

Image classification network in Deep Network Designer. The network starts with an image input layer and ends with a softmax layer.

To adapt this network to your own data, set the InputSize of the image input layer to match your image input size and set the OutputSize of the fully connected layer to the number of classes in your data. For more complex classification tasks, create a deeper network. For more information, see Deep Networks.

For an example showing how to create and train an image classification network, see Get Started with Image Classification.

Sequence Classification

You can use Deep Network Designer to build a sequence network from scratch, or you can use one of the prebuilt untrained networks from the start page. Open the Deep Network Designer start page. Pause on Sequence-to-Label and click Open. Doing so opens a prebuilt network suitable for sequence classification problems.

Sequence classification network in Deep Network Designer. The network starts with a sequence input layer and ends with a softmax layer.

You can adapt this sequence network for training with your data. Suppose you have data with 10 features and 5 classes. To adapt this network, select sequenceInputLayer and set the InputSize to 10.

Sequence input layer selected in Deep Network Designer. The Properties pane shows InputSize set to 10.

Then, select the fullyConnectedLayer and set the OutputSize to 5, the number of classes.

Fully connected layer selected in Deep Network Designer. The Properties pane shows OutputSize set to 5.

For an example showing how to create and train a sequence classification network, see Get Started with Deep Network Designer.

Numeric Data Classification

If you have a data set of numeric features (for example, a collection of numeric data without spatial or time dimensions), then you can train a deep learning network using a feature input layer. For more information about the feature input layer, see featureInputLayer.

You can construct a suitable network using Deep Network Designer, or you can create the network at the command line and import the network into Deep Network Designer.

For example, create a network for numeric data with 10 classes, where each observation consists of 20 features.

inputSize = 20;
numClasses = 10;

layers = [
featureInputLayer(inputSize,Normalization="zscore")
fullyConnectedLayer(50)
batchNormalizationLayer
reluLayer
fullyConnectedLayer(numClasses)
softmaxLayer];

deepNetworkDesigner(layers)

Feature classification network in Deep Network Designer. The network starts with a feature input layer and ends with a softmax layer.

To adapt this network to your own data, set the InputSize of the feature input layer to match the number of features in your data and set the OutputSize of the fully connected layer to the number of classes in your data. For more complex classification tasks, create a deeper network. For more information, see Deep Networks.

Convert Classification Network into Regression Network

You can convert a classification network into a regression network by adapting the final layers of the network. Conversion is useful when you want to take a pretrained classification network and retrain it for regression tasks.

For example, suppose you have a GoogLeNet pretrained network. To convert this network into a regression network with a single response, remove the softmax layer and set the OutputSize of the final fully connected layer to 1 (the number of responses).

Diagram of the conversion of a classification network into a regression network. The final layer of the classification network, a softmax layer, is removed.

If your output has multiple responses, change the OutputSize value of the fully connected layer to the number of responses.

Multiple-Input and Multiple-Output Networks

Multiple Inputs

You can define a network with multiple inputs if the network requires data from multiple sources or in different formats. For example, some networks require image data captured from multiple sensors at different resolutions.

Using Deep Network Designer, you can control the inputs and outputs of each layer. For example, to create a network with multiple image inputs, create two branches, each starting with an image input layer.

Network with multiple inputs in Deep Network Designer. The network has two image input layers and a single softmax layer.

Multiple Outputs

You can define networks with multiple outputs for tasks requiring multiple responses in different formats, for example, tasks requiring both categorical and numeric output.

Using Deep Network Designer, you can control the outputs of each layer.

The end of a network with multiple outputs. The first branch ends with a fully connected layer and a softmax layer. The second branch ends with a fully connected layer.

Deep Networks

Building large networks can be difficult, but you can use Deep Network Designer to speed up construction. You can work with blocks of layers at a time. Select multiple layers, then copy and paste or delete. For example, you can use blocks of layers to create multiple copies of groups of convolution, batch normalization, and ReLU layers.

Group selection of multiple layers in Deep Network Designer.

For trained networks, copying layers also copies the weights and the biases.

You can also copy sub-networks from the workspace to connect up easily using the app. To import a network or layers into the app, click New > Import from workspace. Click Add to add the layers to the current network.

Check Network

To check your network and examine the layers in further detail, click Analyze. Investigate problems and examine the layer properties to resolve size mismatches in the network. Return to Deep Network Designer to edit layers, then check the results by clicking Analyze again. If Deep Learning Network Analyzer reports zero errors, then the edited network is ready for training.

Deep Learning Network Analyzer showing zero warnings or errors.

See Also

| |

Related Topics