RNMTPlusEncoder

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

The RNMT+ encoder described in https://arxiv.org/abs/1804.09849.

Inherits from: opennmt.encoders.SequentialEncoder

__init__(num_layers=6, num_units=1024, cell_class=None, dropout=0.3)[source]

Initializes the parameters of the encoder.

Parameters
  • num_layers – The number of layers.

  • num_units – The number of units in each RNN layer and the final output.

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

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

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