onmt.Batch

A batch of sentences to translate and targets. Manages padding, features, and batch alignment (for efficiency).

Used by the decoder and encoder objects.

[src]

onmt.Batch(src, srcFeatures, tgt, tgtFeatures)

Create a batch object.

Parameters:

  • src - 2D table of source batch indices
  • srcFeatures - 2D table of source batch features (opt)
  • tgt - 2D table of target batch indices
  • tgtFeatures - 2D table of target batch features (opt)

[src]

onmt.Batch:setSourceInput(sourceInput)

Set source input directly,

Parameters:

  • sourceInput - a Tensor of size (sequence_length, batch_size, feature_dim) ,or a sequence of size (sequence_length, batch_size). Be aware that sourceInput is not cloned here.

[src]

onmt.Batch:setTargetInput(targetInput)

Set target input directly.

Parameters:

  • targetInput - a tensor of size (sequence_length, batch_size). Padded with onmt.Constants.PAD. Be aware that targetInput is not cloned here.

[src]

onmt.Batch:setTargetOutput(targetOutput)

Set target output directly.

Parameters:

  • targetOutput - a tensor of size (sequence_length, batch_size). Padded with onmt.Constants.PAD. Be aware that targetOutput is not cloned here.

[src]

onmt.Batch:getSourceInput(t)

Get source input batch at timestep t.

[src]

onmt.Batch:getTargetInput(t)

Get target input batch at timestep t.

[src]

onmt.Batch:getTargetOutput(t)

Get target output batch at timestep t (values t+1).