Pack_padded_sequence changed sequence length

(Zewei Chu) #1

I have the following 2 lines of code

x_packed = nn.utils.rnn.pack_padded_sequence(x[sorted_index_th], lengths_sorted, batch_first=True)
print(nn.utils.rnn.pad_packed_sequence(x_packed, batch_first=True)[0].shape)

and I got the following outputs

torch.Size([39, 377, 300])
torch.Size([39, 121, 300])

I wonder why this happens?
sorted_index_th is a 1 dimensional array of indices to change the order of the first dimension of x.