LSTMEncoder

class opennmt.encoders.LSTMEncoder(*args, **kwargs)[source]

A LSTM sequence encoder.

See also

opennmt.layers.LSTM for differences between this encoder and opennmt.encoders.RNNEncoder with a LSTMCell.

Inherits from: opennmt.encoders.Encoder

__init__(num_layers, num_units, bidirectional=False, residual_connections=False, dropout=0.3, reducer=<opennmt.layers.reducer.ConcatReducer object>, **kwargs)[source]

Initializes the parameters of the encoder.

Parameters
  • num_layers – The number of layers.

  • num_units – The number of units in each layer output.

  • bidirectional – Make each LSTM layer bidirectional.

  • residual_connections – If True, each layer input will be added to its output.

  • dropout – The probability to drop units in each layer output.

  • reducer – A opennmt.layers.Reducer instance to merge bidirectional state and outputs.

  • **kwargs – Additional layer arguments.