LiltLayoutEmbeddingLayer<T>
Layers · AiDotNet.NeuralNetworks.Layers
LiLT’s layout-flow embedding (Wang et al., ACL 2022; reference LiltLayoutEmbeddings). It runs
these steps:
- Six coordinate embeddings, each
hidden / 6wide: x0, y0, x1, y1, the height and the width.
The x table serves both horizontal edges, and the y table both vertical edges.
- The six are concatenated, which gives back
hiddenwhenever it divides by 6, as in every released LiLT;
otherwise it gives the largest multiple of 6 below it, and the linear map sizes itself to that.
- A linear map to the layout flow’s width
hidden / channelShrinkRatio. - A learned reading-order position embedding of that width is added.
- LayerNorm.
Inheritance: LayerBase<T> → LiltLayoutEmbeddingLayer<T>
Implements: IShapeContract
For Beginners
This turns each word’s bounding box into a vector for LiLT’s small layout transformer, which runs beside the text transformer.
How It Works
The input is one box per token, [S, 4] or [B, S, 4], as integer (x0, y0, x1, y1) on
the 0-1000 page grid. Coordinates are clamped into the tables, as the reference requires them to be.
Constructors
| Constructor | Summary |
|---|---|
LiltLayoutEmbeddingLayer(int hiddenDim, int maxSequenceLength, int maxPosition2D, int channelShrinkRatio) |
Creates the embedding. |
Properties
| Property | Summary |
|---|---|
IReadOnlyList<LayerPort> InputPorts { get; } |
Generated from [TensorPort] declarations. |
IReadOnlyList<LayerPort> OutputPorts { get; } |
Generated from [TensorPort] declarations. |
bool SupportsTraining { get; } |
|
int LayoutDim { get; } |
Width of the layout flow this embedding feeds: hidden / channelShrinkRatio. |
Methods
| Method | Summary |
|---|---|
IReadOnlyList<ILayer<T>> GetSubLayers() |
|
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank) |
|
LayerInputDomain GetInputDomain(int[] inputShape) |
Generated from the primary [TensorPort] declaration. |
void ResetState() |