add_sequence_controls
- opennmt.inputters.add_sequence_controls(ids, length=None, start_id=None, end_id=None, pad_id=0)[source]
Adds sequence control tokens.
- Parameters
ids – Sequence of token ids as a 1D
tf.Tensor, a 2Dtf.Tensor, or a 2Dtf.RaggedTensor.length – Length of each sequence in the batch as a 1D
tf.Tensor. Required ifidsis a 2Dtf.Tensor.start_id – Token id to prepend to the sequences (set
Noneto disable).end_id – Token id to append to the sequences (set
Noneto disable).pad_id – Padding token ID.
- Returns
The updated token ids, and optionally the updated length if it was initially passed as argument.
- Raises
ValueError – if
idsis a dense 2Dtf.Tensor, butlengthis not set.ValueError – if the rank of
idsis not 1 or 2.