Main Content

disconnectLayers

Disconnect layers in layer graph or network

Description

example

lgraphUpdated = disconnectLayers(lgraph,s,d) disconnects the source layer s from the destination layer d in the layer graph lgraph. The updated layer graph, lgraphUpdated, contains the same layers as lgraph, but excludes the connection between s and d.

netUpdated = disconnectLayers(net,s,d) disconnects the source layer s from the destination layer d in the dlnetwork object net. The updated network, netUpdated, contains the same layers as net, but excludes the connection between s and d.

Examples

collapse all

Create a layer graph from an array of layers.

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

lgraph = layerGraph(layers);
figure
plot(lgraph)

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

Disconnect the 'conv_1' layer from the 'BN_1' layer.

lgraph = disconnectLayers(lgraph,'conv_1','BN_1');
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.

Connection source, specified as a character vector or a string scalar.

  • If the source layer has a single output, then s is the name of the layer.

  • If the source layer has multiple outputs, then s is the layer name followed by the character / and the name of the layer output: 'layerName/outputName'.

Example: 'conv1'

Example: 'mpool/indices'

Connection destination, specified as a character vector or a string scalar.

  • If the destination layer has a single input, then d is the name of the layer.

  • If the destination layer has multiple inputs, then d is the layer name followed by the character / and the name of the layer input: 'layerName/inputName'.

Example: 'fc'

Example: 'addlayer1/in2'

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.

The disconnectLayers function does not preserve quantization information. If the input network is a quantized network, then the output network does not contain quantization information.

Version History

Introduced in R2017b