Main Content

addLayers

Add layers to layer graph or network

Description

example

lgraphUpdated = addLayers(lgraph,larray) adds the network layers in larray to the layer graph lgraph. The updated layer graph lgraphUpdated contains the layers and connections of lgraph together with the layers in larray, connected sequentially. The layer names in larray must be unique, nonempty, and different from the names of the layers in lgraph.

netUpdated = addLayers(net,larray) adds the network layers in larray to the dlnetwork object net. The updated network netUpdated contains the layers and connections of net together with the layers in larray, connected sequentially. The layer names in larray must be unique, nonempty, and different from the names of the layers in net.

Examples

collapse all

Create an empty layer graph and an array of layers. Add the layers to the layer graph and plot the graph. addLayers connects the layers sequentially.

lgraph = layerGraph;

layers = [
    imageInputLayer([32 32 3],'Name','input')  
    convolution2dLayer(3,16,'Padding','same','Name','conv_1')
    batchNormalizationLayer('Name','BN_1')
    reluLayer('Name','relu_1')];

lgraph = addLayers(lgraph,layers);
figure
plot(lgraph)

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

Input Arguments

collapse all

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

Neural network, specified as a dlnetwork object.

Network layers, specified as a Layer array.

For a list of built-in layers, see List of Deep Learning Layers.

Output Arguments

collapse all

Updated layer graph, returned as a LayerGraph object.

Updated network, returned as an uninitialized dlnetwork object.

To initialize the learnable parameters of a dlnetwork object, use the initialize function.

Version History

Introduced in R2017b