ConcatenateLayer<T>
Layers · AiDotNet.NeuralNetworks.Layers
Represents a neural network layer that concatenates multiple inputs along a specified axis.
Inheritance: LayerBase<T> → ConcatenateLayer<T>
Implements: IMultiPortShapeContract
For Beginners
A concatenate layer joins multiple inputs together to make one bigger output.
Think of it like joining arrays or lists:
- If you have two lists [1, 2, 3] and [4, 5], concatenating them gives [1, 2, 3, 4, 5]
In neural networks, we often work with multi-dimensional data, so we need to specify which dimension (axis) to join along:
- Axis 0 would join along the first dimension (like stacking sheets of paper)
- Axis 1 would join along the second dimension (like extending rows sideways)
- Axis 2 would join along the third dimension (like extending columns downward)
For example, if you have:
- One tensor representing features from an image: [batch_size, 100]
- Another tensor representing features from text: [batch_size, 50]
You could use a concatenate layer with axis=1 to create a combined feature tensor of shape [batch_size, 150] that contains both sets of features side by side.
How It Works
A concatenate layer combines multiple input tensors into a single output tensor by joining them along a specified axis. For example, if you have two tensors of shape [batch_size, 10] and [batch_size, 15], concatenating them along axis 1 would produce a tensor of shape [batch_size, 25]. This layer doesn’t have any trainable parameters and simply passes the gradients back to the appropriate input tensors during backpropagation.
Constructors
| Constructor | Summary |
|---|---|
ConcatenateLayer(int[][] inputShapes, int axis, IActivationFunction<T> activationFunction) |
Initializes a new instance of the ConcatenateLayer class with a vector activation function. |
ConcatenateLayer(int[][] inputShapes, int axis, IVectorActivationFunction<T> vectorActivationFunction) |
Initializes a new instance of the ConcatenateLayer class with a vector activation function. |
Properties
| Property | Summary |
|---|---|
IReadOnlyList<LayerPort> InputPorts { get; } |
|
bool SupportsGpuTraining { get; } |
|
bool SupportsTraining { get; } |
Gets a value indicating whether this layer supports training. |
Methods
| Method | Summary |
|---|---|
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank) |
|
IReadOnlyList<OutputAxisContract> OutputAxesForPorts(IReadOnlyList<int> inputRanks) |
|
void ResetState() |
Resets the internal state of the concatenate layer. |