EncoderDecoderTransformer class

Inheritance

Constructors

EncoderDecoderTransformer({required int sourceVocabSize, required int targetVocabSize, required int embedDim, required int numLayers, required int numHeads, required int maxSourceLen, required int maxTargetLen, int? ffnDim, double dropoutP = 0.0, Device device = Device.CPU, int seed = 0})

Properties

decoder TransformerDecoder
final
embedDim int
final
encoder TransformerEncoder
final
hashCode int
The hash code for this object.
no setterinherited
final
maxSourceLen int
final
maxTargetLen int
final
numHeads int
final
numLayers int
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sourceEmb Embedding
final
sourceVocabSize int
final
srcPosEnc SinusoidalPositionalEncoding
final
targetEmb Embedding
final
targetVocabSize int
final
tgtPosEnc SinusoidalPositionalEncoding
final
training bool
Whether this module is in training mode. Layers that behave differently between training and inference (e.g. Dropout) read this flag in their call method. Defaults to training mode.
getter/setter pairinherited

Methods

call(Tensor srcTokens, Tensor tgtTokens) Tensor
Full forward: encode source, decode target against memory, return logits [St, targetVocabSize] or [B, St, V].
decode(Tensor tgtTokens, Tensor memory) Tensor
Decoder-side forward given a precomputed memory (encoder output). Applies causal masking to the decoder self-attention.
encode(Tensor srcTokens) Tensor
Encoder-only pass returning "memory" for the decoder.
eval() → void
Put this module (and any registered submodules) into evaluation mode.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parameters() List<Tensor>
Trainable tensors owned by this module (and its submodules).
override
submodules() List<Module>
Submodules owned by this module. Subclasses that compose other modules should override this so train() / eval() propagate. Default: empty.
override
toString() String
A string representation of this object.
inherited
train() → void
Put this module (and any registered submodules) into training mode.
inherited
zeroGrad() → void
Zero every parameter's gradient. Safe to call before each backward.
inherited

Operators

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