Packs a list of variable length Tensors.
Consecutive call of the next functions: pad_sequence
, pack_padded_sequence
.
sequences
should be a list of Tensors of size L x *
, where L is the length of a sequence and * is any number of trailing dimensions, including 0
.
For unsorted sequences, use enforce_sorted = False. If enforce_sorted
is True
, the sequences should be sorted in the order of decreasing length. enforce_sorted = True
is only necessary for ONNX export.
Example
>>> from torch.nn.utils.rnn import pack_sequence >>> a = torch.tensor([1, 2, 3]) >>> b = torch.tensor([4, 5]) >>> c = torch.tensor([6]) >>> pack_sequence([a, b, c]) PackedSequence(data=tensor([1, 4, 6, 2, 5, 3]), batch_sizes=tensor([3, 2, 1]), sorted_indices=None, unsorted_indices=None)
a PackedSequence
object
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4