Encoder
- class opennmt.encoders.Encoder(*args, **kwargs)[source]
Base class for encoders.
Inherits from:
keras.src.engine.base_layer.Layer
Extended by:
- abstract call(inputs, sequence_length=None, training=None)[source]
Encodes an input sequence.
- Parameters
inputs – The inputs to encode of shape \([B, T, ...]\).
sequence_length – The length of each input with shape \([B]\).
training – Run in training mode.
- Returns
A tuple
(outputs, state, sequence_length)
.
- __call__(inputs, sequence_length=None, **kwargs)[source]
Encodes an input sequence.
- Parameters
inputs – A 3D
tf.Tensor
ortf.RaggedTensor
.sequence_length – A 1D
tf.Tensor
(optional ifinputs
is atf.RaggedTensor
).training – Run the encoder in training mode.
- Returns
If
inputs
is atf.Tensor
, the encoder returns a tuple(outputs, state, sequence_length)
. Ifinputs
is atf.RaggedTensor
, the encoder returns a tuple(outputs, state)
, whereoutputs
is atf.RaggedTensor
.