Main Content

removeLayers

Remove layers from layer graph

Description

example

newlgraph= removeLayers(lgraph,layerNames)removes the layers specified bylayerNamesfrom the layer graphlgraph. The function also removes any connections to the removed layers.

Examples

collapse all

Create a layer graph from an array of layers.

layers = [ imageInputLayer([28 28 1],'Name',“输入”) 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.

Remove the'BN_1'layer and its connections.

lgraph = removeLayers(lgraph,'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 aLayerGraphobject. To create a layer graph, uselayerGraph.

Names of layers to remove, specified as a character vector, a cell array of character vectors, or a string array.

To remove a single layer from the layer graph, specify the name of the layer.

To remove multiple layers, specify the layer names in an array, where each element of the array is a layer name.

Example:'conv1'

Example:{'conv1','add1'}

Output Arguments

collapse all

Output layer graph, returned as aLayerGraphobject.

版本History

Introduced in R2017b