SwinPatchMergingLayer<T>
Layers · AiDotNet.NeuralNetworks.Layers
Patch merging layer for Swin Transformer that performs downsampling between stages.
Inheritance: LayerBase<T> → SwinPatchMergingLayer<T>
Implements: IShapeContract
For Beginners
Think of this like pooling in CNNs, but instead of taking max or average, we concatenate 4 neighboring patches together (2x2 grid) and then use a linear layer to reduce the combined channels. This lets the network process information at multiple scales.
How It Works
This layer merges 2x2 neighboring patches into a single patch, reducing spatial resolution by half while doubling the channel dimension. This creates the hierarchical structure characteristic of Swin Transformer.
Reference: Liu et al., “Swin Transformer: Hierarchical Vision Transformer using Shifted Windows”, ICCV 2021
Constructors
| Constructor | Summary |
|---|---|
SwinPatchMergingLayer(int inputDim) |
Creates a new Swin patch merging layer. |
Properties
| Property | Summary |
|---|---|
bool SupportsTraining { get; } |
Methods
| Method | Summary |
|---|---|
IReadOnlyList<ILayer<T>> GetSubLayers() |
|
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank) |
|
void ClearGradients() |
|
void ResetState() |
|
void UpdateParameters(T learningRate) |