Main Content

disconnectLayers

Disconnect layers in neural network

Description

example

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 simple neural network and display it in a plot.

net = dlnetwork;

layers = [
    imageInputLayer([28 28 1])  
    convolution2dLayer(3,16,Padding="same")
    batchNormalizationLayer
    reluLayer];

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

Disconnect the layer with the names "conv" and "batchnorm".

net = disconnectLayers(net,"conv","batchnorm");

Display the updated network in a plot.

figure
plot(net)

Input Arguments

collapse all

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: "conv"

Example: "mpool/indices"

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

  • 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: "add/in1"

Output Arguments

collapse all

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

expand all