torch.nn.utils.rnn.pad_sequence
- torch.nn.utils.rnn.pad_sequence(sequences, batch_first=False, padding_value=0.0, padding_side='right')
Pad a list of variable length Tensors with
padding_value.stacks a list of Tensors along a new dimension, and pads them to equal length. can be list of sequences with size , where is length of the sequence and is any number of dimensions (including ). If is , the output is of size , and otherwise, where is the batch size (the number of elements in ), is the length of the longest sequence.