plot - Plot neural network architecture - MATLAB (original) (raw)

Main Content

Plot neural network architecture

Syntax

Description

plot([net](#mw%5F2efcc0fc-bacb-4a51-ad8e-4f38e8fc5f63%5Fsep%5Fmw%5F3ffb42b3-6af7-4c22-82b3-4fb0f6a399f2)) plots the layers and connections of the neural network net.

Tip

To create an interactive network visualization and analyze the network architecture, use deepNetworkDesigner(net). For more information, see Deep Network Designer.

example

Examples

collapse all

Create a simple neural network and display it in a plot.

net = dlnetwork;

layers = [ imageInputLayer([32 32 3]) convolution2dLayer(3,16,Padding="same") batchNormalizationLayer reluLayer(Name="relu1")

convolution2dLayer(3,16,Padding="same",Stride=2)
batchNormalizationLayer
reluLayer
additionLayer(2,Name="add")];

net = addLayers(net,layers); net = connectLayers(net,"relu1","add/in2");

figure plot(net)

Figure contains an axes object. The axes object contains an object of type graphplot.

Version History

Introduced in R2017b

expand all

Starting in R2024a, DAGNetwork, SeriesNetwork, and LayerGraph objects are not recommended. Use dlnetwork objects instead. This recommendation means that the that plot function is not recommended with inputs of these objects.

To convert a trained DAGNetwork or SeriesNetwork object to a dlnetwork object, use the dag2dlnetwork function.

Most functions that support LayerGraph objects also supportdlnetwork objects. This table shows some typical usages ofLayerGraph objects and how to update your code to usedlnetwork object functions instead.

Not Recommended Recommended
lgraph = layerGraph; net = dlnetwork;
lgraph = layerGraph(layers); net = dlnetwork(layers,Initialize=false);
lgraph = layerGraph(net); net = dag2dlnetwork(net);
lgraph = addLayers(lgraph,layers); net = addLayers(net,layers);
lgraph = removeLayers(lgraph,layerNames); net = removeLayers(net,layerNames);
lgraph = replaceLayer(lgraph,layerName,layers); net = replaceLayer(net,layerName,layers);
lgraph = connectLayers(lgraph,s,d); net = connectLayers(net,s,d);
lgraph = disconnectLayers(lgraph,s,d); net = disconnectLayers(net,s,d);
plot(lgraph); plot(net);

To train a neural network specified as a dlnetwork object, use the trainnet function.