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.Encoder
Extended 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.Reducer
to 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
i
th callable will be applied between encodersi
andi + 1
.
- Raises
ValueError – if
transition_layer_fn
is a list with a size not equal to the number of encoder transitionslen(encoders) - 1
.