Main Content


Depth concatenation layer


A depth concatenation layer takes inputs that have the same height and width and concatenates them along the channel dimension.

Specify the number of inputs to the layer when you create it. The inputs have the names 'in1','in2',...,'inN', where N is the number of inputs. Use the input names when connecting or disconnecting the layer by using connectLayers or disconnectLayers.




layer = depthConcatenationLayer(numInputs) creates a depth concatenation layer that concatenates numInputs inputs along the channel dimension. This function also sets the NumInputs property.


layer = depthConcatenationLayer(numInputs,'Name',name) also sets the Name property.


expand all

Number of inputs to the layer, specified as a positive integer greater than or equal to 2.

The inputs have the names 'in1','in2',...,'inN', where N is NumInputs. For example, if NumInputs is 3, then the inputs have the names 'in1','in2', and 'in3'. Use the input names when connecting or disconnecting the layer using the connectLayers or disconnectLayers functions.

Layer name, specified as a character vector or a string scalar. For Layer array input, the trainnet and dlnetwork functions automatically assign names to layers with the name "".

The DepthConcatenationLayer object stores this property as a character vector.

Data Types: char | string

Input names, specified as {'in1','in2',...,'inN'}, where N is the number of inputs of the layer.

Data Types: cell

This property is read-only.

Number of outputs from the layer, returned as 1. This layer has a single output only.

Data Types: double

This property is read-only.

Output names, returned as {'out'}. This layer has a single output only.

Data Types: cell


collapse all

Create a depth concatenation layer with two inputs and the name 'concat_1'.

concat = depthConcatenationLayer(2,'Name','concat_1')
concat = 
  DepthConcatenationLayer with properties:

          Name: 'concat_1'
     NumInputs: 2
    InputNames: {'in1'  'in2'}

Create two ReLU layers and connect them to the depth concatenation layer. The depth concatenation layer concatenates the outputs from the ReLU layers.

relu_1 = reluLayer('Name','relu_1');
relu_2 = reluLayer('Name','relu_2');

net = dlnetwork;
net = addLayers(net,relu_1);
net = addLayers(net,relu_2);
net = addLayers(net,concat);

net = connectLayers(net,'relu_1','concat_1/in1');
net = connectLayers(net,'relu_2','concat_1/in2');



expand all

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

Version History

Introduced in R2017b

expand all