Encoder
- class opennmt.encoders.Encoder(*args, **kwargs)[source]
Base class for encoders.
Inherits from:
keras.src.engine.base_layer.LayerExtended 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.Tensorortf.RaggedTensor.sequence_length – A 1D
tf.Tensor(optional ifinputsis atf.RaggedTensor).training – Run the encoder in training mode.
- Returns
If
inputsis atf.Tensor, the encoder returns a tuple(outputs, state, sequence_length). Ifinputsis atf.RaggedTensor, the encoder returns a tuple(outputs, state), whereoutputsis atf.RaggedTensor.