WordPairGridLayer<T>

Layers · AiDotNet.NeuralNetworks.Layers

W2NER’s word-pair relation classifier (Li et al. 2022, “Unified Named Entity Recognition as Word-Word Relation Classification”, section 3): conditional layer normalization builds a grid V_ij = gamma_ij * (h_j - mu) / sigma + lambda_ij with gamma_ij and lambda_ij linear in h_i (Equations 1 and 2); distance and region embeddings are concatenated and an MLP reduces the grid to dc channels (Equation 3); three depthwise 3x3 convolutions with dilation rates 1, 2 and 3 and GELU, applied in sequence as the authors’ code does, refine it (Equation 4); and a co-predictor sums an MLP over the refined grid with a biaffine classifier over the word representations (Equations 5 to 9).

Inheritance: LayerBase<T> → WordPairGridLayer<T>

Implements: IShapeContract

How It Works

Shapes: input [B, S, D] (or [S, D]) word representations; output [B, S * S, R], the relation scores of every word pair (row i, column j) at index i * S + j, R being None, NNW and one THW per entity type.

Distances use W2NER’s buckets (0, 1, 2-3, 4-7, …, 256+, signed, with a separate bucket for the diagonal); regions distinguish the lower triangle (diagonal included) from the upper.

Constructors

Constructor Summary
WordPairGridLayer(int inputDim, int channels, int hiddenDim, int biaffineDim, int numRelations) Creates the classifier.

Properties

Property Summary
bool SupportsTraining { get; }

Methods

Method Summary
IReadOnlyList<ILayer<T>> GetSubLayers()
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank)
void ResetState()