EmbeddingLayer class

A layer that turns a 1D vector of integer indices into a 2D matrix of dense vectors.

This layer is the standard first step for processing a single sequence of text for a Natural Language Processing (NLP) task.

  • Input: A Tensor<Vector> where the vector contains integer indices representing a single sequence of words.
  • Output: A Tensor<Matrix> representing the sequence of embedding vectors, with a shape of [sequence_length, embeddingDimension].
Inheritance

Constructors

EmbeddingLayer(int vocabularySize, int embeddingDimension)

Properties

embeddingDimension int
getter/setter pair
embeddings Tensor<Matrix>
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
name String
A user-friendly name for the layer (e.g., 'dense', 'lstm').
getter/setter pairoverride-getter
parameters List<Tensor>
A list of all trainable tensors (weights and biases) in the layer.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
vocabularySize int
getter/setter pair

Methods

build(Tensor input) → void
Initializes the layer's parameters based on the shape of the first input.
override
call(Tensor input) Tensor
The public, callable interface for the layer.
inherited
forward(Tensor input) Tensor<Matrix>
The core logic of the layer's transformation.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited