SwinPatchEmbeddingLayer<T>
Layers · AiDotNet.NeuralNetworks.Layers
Patch embedding layer for Swin Transformer that converts images to patch sequences.
Inheritance: LayerBase<T> → SwinPatchEmbeddingLayer<T>
Implements: IShapeContract
For Beginners
Think of this layer as cutting an image into small squares (patches) and converting each square into a list of numbers (embedding) that describes its content. This allows the transformer to process images as sequences, similar to how it processes text.
How It Works
This layer divides an input image into non-overlapping patches and projects each patch to an embedding vector. This is the first step in processing images with Swin Transformer.
Reference: Liu et al., “Swin Transformer: Hierarchical Vision Transformer using Shifted Windows”, ICCV 2021
Constructors
| Constructor | Summary |
|---|---|
SwinPatchEmbeddingLayer(int patchSize, int embedDim) |
Creates a new Swin patch embedding layer. |
Properties
| Property | Summary |
|---|---|
bool SupportsTraining { get; } |
|
int NumPatches { get; } |
Gets the number of patches produced by this layer. |
int PatchGridHeight { get; } |
Gets the height of the patch grid. |
int PatchGridWidth { get; } |
Gets the width of the patch grid. |
Methods
| Method | Summary |
|---|---|
IReadOnlyList<ILayer<T>> GetSubLayers() |
|
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank) |
|
void ClearGradients() |
|
void ResetState() |
|
void UpdateParameters(T learningRate) |