According to the PyTorch manual, if you want to feed a batch of variable-length sequences to a sequence model, you pad and pack the batch before feeding it to the sequence model. That is,
lstm = LSTM(bidrectional=True) packed_batch = pack_padded_sequence(batch) output, (h_n, c_n) = lstm(packed_batch)
In this case, if I do output[-1, :, :], what would be the result?
Suppose that the first sequence in the batch has the length 7 and that the maximum length is 10 -- that is, the first sequence will receive 3 paddings.
If I do output[-1,0,:] (to retrieve the last hidden state of the first sequence), does it return the concatenation of the 7-th hidden states of the bi-LSTM (which is the correct)? Or, would it return be still the concatenation of the 10-th hidden states?