Hello everyone!

I can’t clearly understand how packed sequence works. If we look at the example from the docs:

a = torch.tensor([1, 2, 3])

b = torch.tensor([1, 2])

c = torch.tensor([1])torch.nn.utils.rnn.pack_sequence([a, b, c])

it will give us something like that:

PackedSequence(data=tensor([ 1, 1, 1, 2, 2, 3]), batch_sizes=tensor([ 3, 2, 1]))

But when I change only one tensor, it gives completely different results:

a = torch.zeros(5)

b = torch.tensor([1, 2])

c = torch.tensor([1])torch.nn.utils.rnn.pack_sequence([a, b, c])

PackedSequence(data=tensor([ 0., 1., 1., 0., 2., 0., 0., 0.]), batch_sizes=tensor([ 3, 2, 1, 1, 1]))

What’s going on? Why we obtain batch_sizes with 5 elements when we gave only 3 tensors?