RNNEncoder

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

A RNN sequence encoder.

Inherits from: opennmt.encoders.Encoder

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

Initializes the parameters of the encoder.

Parameters
  • num_layers – The number of layers.

  • num_units – The number of units in each layer.

  • bidirectional – Use a bidirectional RNN.

  • 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.

  • cell_class – The inner cell class or a callable taking num_units as argument and returning a cell. Defaults to a LSTM cell.

  • **kwargs – Additional layer arguments.

map_v1_weights(weights)[source]