DepthConcatenationLayer - Depth concatenation layer - MATLAB (original) (raw)
Depth concatenation layer
Description
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 usingconnectLayers or disconnectLayers.
Creation
Syntax
Description
`layer` = depthConcatenationLayer(`numInputs`)
creates a depth concatenation layer that concatenatesnumInputs
inputs along the channel dimension. This function also sets the NumInputs property.
`layer` = depthConcatenationLayer(`numInputs`,'Name',name)
also sets the Name property.
Properties
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
isNumInputs
. 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.
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, stored as 1
. This layer has a single output only.
Data Types: double
This property is read-only.
Output names, stored as {'out'}
. This layer has a single output only.
Data Types: cell
Examples
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');
plot(net)
Algorithms
Layers in a layer array or layer graph pass data to subsequent layers as formatted dlarray objects. The format of a dlarray
object is a string of characters in which each character describes the corresponding dimension of the data. The format consists of one or more of these characters:
"S"
— Spatial"C"
— Channel"B"
— Batch"T"
— Time"U"
— Unspecified
For example, you can describe 2-D image data that is represented as a 4-D array, where the first two dimensions correspond to the spatial dimensions of the images, the third dimension corresponds to the channels of the images, and the fourth dimension corresponds to the batch dimension, as having the format "SSCB"
(spatial, spatial, channel, batch).
You can interact with these dlarray
objects in automatic differentiation workflows, such as those for developing a custom layer, using a functionLayer object, or using the forward and predict functions withdlnetwork
objects.
This table shows the supported input formats of DepthConcatenationLayer
objects and the corresponding output format. If the software passes the output of the layer to a custom layer that does not inherit from the nnet.layer.Formattable
class, or aFunctionLayer
object with the Formattable
property set to 0
(false
), then the layer receives an unformatted dlarray
object with dimensions ordered according to the formats in this table. The formats listed here are only a subset. The layer may support additional formats such as formats with additional "S"
(spatial) or"U"
(unspecified) dimensions.
The output format matches the input format.
Input Format | Output Format |
---|---|
"SSCB" (spatial, spatial, channel, batch) | "SSCB" (spatial, spatial, channel, batch) |
"SSSCB" (spatial, spatial, spatial, channel, batch) | "SSSCB" (spatial, spatial, spatial, channel, batch) |
"SSCBT" (spatial, spatial, channel, batch, time) | "SSCBT" (spatial, spatial, channel, batch, time) |
"SSSCBT" (spatial, spatial, spatial, channel, batch, time) | "SSSCBT" (spatial, spatial, spatial, channel, batch, time) |
"SSC" (spatial, spatial, channel) | "SSC" (spatial, spatial, channel) |
"SSSC" (spatial, spatial, spatial, channel) | "SSSC" (spatial, spatial, spatial, channel) |
In dlnetwork
objects, DepthConcatenationLayer
objects also support these input and output format combinations.
Input Format | Output Format |
---|---|
"SSCT" (spatial, spatial, channel, time) | "SSCT" (spatial, spatial, channel, time) |
"SSSCT" (spatial, spatial, spatial, channel, time) | "SSSCT" (spatial, spatial, spatial, channel, time) |
DepthConcatenationLayer
objects support complex-valued input and outputs. (since R2024a) The layer applies the same underlying operation to complex-valued input as it does to real-valued input and outputs complex-valued data where applicable.
Extended Capabilities
Version History
Introduced in R2017b
DepthConcatenationLayer
objects support complex-valued input and outputs. The layer applies the same underlying operation to complex-valued input as it does to real-valued input and outputs complex-valued data where applicable.