I was trying to replicate How to use packing for variable-length sequence inputs for rnn but I guess I first need to understand why we need to \"pack\" the sequence.
<
Adding to Umang's answer, I found this important to note.
The first item in the returned tuple of pack_padded_sequence is a data (tensor)- tensor containing packed sequence. The second item is a tensor of integers holding information about the batch size at each sequence step.
What's important here though is the second item (Batch sizes) represents the number of elements at each sequence step in the batch, not the varying sequence lengths passed to pack_padded_sequence.
For instance, given data abc and x
the :class:PackedSequence would contain data axbc with
batch_sizes=[2,1,1].