plot

Plot neural network layer graph

Syntax

plot(lgraph)
plot(dagNet)

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(dagNet) plots a diagram of the layers in the directed acyclic graph (DAG) network dagNet.

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)

Input Arguments

collapse all

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

DAG network, specified as a DAGNetwork object.

Introduced in R2017b