SequentialEncoder
- class opennmt.encoders.SequentialEncoder(*args, **kwargs)[source]
An encoder that executes multiple encoders sequentially with optional transition layers.
See for example “Cascaded Encoder” in https://arxiv.org/abs/1804.09849.
Inherits from:
opennmt.encoders.EncoderExtended by:
- __init__(encoders, states_reducer=<opennmt.layers.reducer.JoinReducer object>, transition_layer_fn=None)[source]
Initializes the parameters of the encoder.
- Parameters
encoders – A list of
opennmt.encoders.Encoder.states_reducer – A
opennmt.layers.Reducerto merge all states.transition_layer_fn – A callable or list of callables applied to the output of an encoder before passing it as input to the next. If it is a single callable, it is applied between every encoders. Otherwise, the
ith callable will be applied between encodersiandi + 1.
- Raises
ValueError – if
transition_layer_fnis a list with a size not equal to the number of encoder transitionslen(encoders) - 1.