opennmt.utils.roll_sequence

opennmt.utils.roll_sequence(tensor, offsets)[source]

Shifts sequences by an offset.

Parameters
  • tensor – A tf.Tensor of shape \([B, T, ...]\).

  • offsets – The offset of each sequence of shape \([B]\).

Returns

A tf.Tensor with the same shape as tensor and with sequences shifted by offsets.