Hi,
I am new to PyTorch. I am currently using a simple lstm encoder for my variable length sequences. I notice something strange. When I feed the same inputs in a batch, the lstm outputs for each identical input is different. That is, say my variable length sequence all begin with the input 1, the hidden state after the first step is different for all of them.
What am I doing wrong ? (I am definitely sure that it is the self.hidden that I am passing which creates this issue)
pack_wv = torch.nn.utils.rnn.pack_padded_sequence(batch_in_wv_sorted, seq_lengths_sorted, batch_first=True)
out, (ht,ct) = self.lstm(pack_wv, self.hidden)
When I change the last line to
out, (ht,ct) = self.lstm(pack_wv)
The issue goes away. But I am afraid that this will lead to incorrect behavior, since we are expected to pass the self.hidden for the intialised first hidden state.