RNNDecoder

class opennmt.decoders.RNNDecoder(*args, **kwargs)[source]

A basic RNN decoder.

Inherits from: opennmt.decoders.Decoder

Extended by:

__init__(num_layers, num_units, bridge_class=None, cell_class=None, dropout=0.3, residual_connections=False, **kwargs)[source]

Initializes the decoder parameters.

Parameters
  • num_layers – The number of layers.

  • num_units – The number of units in each layer.

  • bridge_class – A opennmt.layers.Bridge class to pass the encoder state to the decoder. Default to opennmt.layers.ZeroBridge.

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

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

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

  • **kwargs – Additional layer arguments.

step(inputs, timestep, state=None, memory=None, memory_sequence_length=None, training=None)[source]

Runs one decoding step.

Parameters
  • inputs – The 2D decoder input.

  • timestep – The current decoding step.

  • state – The decoder state.

  • memory – Memory values to query.

  • memory_sequence_length – Memory values length.

  • training – Run in training mode.

Returns

A tuple with the decoder outputs, the decoder state, and the attention vector.