plot

Plot neural network layer graph

Description

example

plot(lgraph) plots a diagram of the layer graph lgraph. The plot function labels each layer by its name and displays all layer connections.

Tip

To analyze the network architecture and create an interactive network visualization, use analyzeNetwork.

example

plot(net) plots a diagram of the network net.

Examples

collapse all

Create a layer graph from an array of layers. Connect the 'relu_1' layer to the 'add' layer.

layers = [
    imageInputLayer([32 32 3],'Name','input')   
    convolution2dLayer(3,16,'Padding','same','Name','conv_1')
    batchNormalizationLayer('Name','BN_1')
    reluLayer('Name','relu_1')
    
    convolution2dLayer(3,16,'Padding','same','Stride',2,'Name','conv_2')
    batchNormalizationLayer('Name','BN_2')
    reluLayer('Name','relu_2') 
    additionLayer(2,'Name','add')];

lgraph = layerGraph(layers);
lgraph = connectLayers(lgraph,'relu_1','add/in2');

Plot the layer graph.

figure
plot(lgraph);

Load a pretrained GoogLeNet convolutional neural network as a DAGNetwork object. If the Deep Learning Toolbox™ Model for GoogLeNet Network support package is not installed, then the software provides a download link.

net = googlenet
net = 
  DAGNetwork with properties:

         Layers: [144×1 nnet.cnn.layer.Layer]
    Connections: [170×2 table]

Plot the network.

figure('Units','normalized','Position',[0.1 0.1 0.8 0.8]);
plot(net)

Load a pretrained AlexNet convolutional neural network as a SeriesNetwork object. If the Deep Learning Toolbox™ Model for AlexNet Network support package is not installed, then the software provides a download link.

net = alexnet
net = 
  SeriesNetwork with properties:

         Layers: [25x1 nnet.cnn.layer.Layer]
     InputNames: {'data'}
    OutputNames: {'output'}

Plot the network.

plot(net)

Input Arguments

collapse all

Layer graph, specified as a LayerGraph object. To create a layer graph, use layerGraph.

Network architecture, specified as a SeriesNetwork or a DAGNetwork object.

Introduced in R2017b