onmt.Encoder

Encoder is a unidirectional Sequencer used for the source language.

h_1 => h_2 => h_3 => ... => h_n
 |      |      |             |
 .      .      .             .
 |      |      |             |
h_1 => h_2 => h_3 => ... => h_n
 |      |      |             |
 |      |      |             |
x_1    x_2    x_3           x_n

Inherits from onmt.Sequencer.

[src]

onmt.Encoder(args, inputNetwork)

Construct an Encoder layer.

Parameters:

  • inputNetwork - input module.
  • rnn - recurrent module.

[src]

onmt.Encoder.load(pretrained)

Return a new Encoder using the serialized data pretrained.

[src]

onmt.Encoder:serialize()

Return data to serialize.

[src]

onmt.Encoder:forward(batch)

Compute the context representation of an input.

Parameters:

  • batch - as defined in batch.lua.

Returns:

    • final hidden states
    • context matrix H

[src]

onmt.Encoder:backward(batch, gradStatesOutput, gradContextOutput)

Backward pass (only called during training)

Parameters:

  • batch - must be same as for forward
  • gradStatesOutput gradient of loss wrt last state - this can be null if states are not used
  • gradContextOutput - gradient of loss wrt full context.

Returns: gradInputs of input network.

Undocumented methods

* onmt.Encoder.declareOpts(cmd) * onmt.Encoder:resetPreallocation() * onmt.Encoder:maskPadding()