TransformerEncoderBlock class
Implements a single Transformer Encoder Block.
This is the main repeating component of the Transformer's encoder. It consists of two primary sub-layers: a Multi-Head Self-Attention mechanism and a position-wise Feed-Forward Network. Each sub-layer is followed by a residual connection and a layer normalization step.
By stacking these blocks, the model can build an increasingly deep and context-aware representation of the input sequence.
Constructors
- TransformerEncoderBlock(int dModel, int numHeads, int dff)
Properties
- dff ↔ int
-
getter/setter pair
- dModel ↔ int
-
getter/setter pair
- ffn ↔ SNetwork
-
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- layerNorm1 ↔ LayerNormalization
-
getter/setter pair
- layerNorm2 ↔ LayerNormalization
-
getter/setter pair
- mha ↔ MultiHeadAttention
-
getter/setter pair
- name ↔ String
-
A user-friendly name for the layer (e.g., 'dense', 'lstm').
getter/setter pairoverride-getter
- numHeads ↔ int
-
getter/setter pair
-
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
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