My rnn generates the same outputs for each item in the minibatch, how to debug this?

I’ve built a very simple RNN. I found an issue where outputs is generating nonsense. I was debugging it and found that my rnn output is generating the same exact output for each item in the minibatch. Can anyone tell me if Im doing something wrong with my code? I have looked at this code over a few times and I cant find where the error is being introduced. can anyone give me an idea of how to debug this?

I’d probably take a very sharp look at batch_first=True in conjunction with the [0] here:

Best regards


rnn_features are all output tensors of your sequence, so rnn_features shape is (batch_size, sequence_length, output_size). If you wanna get last output, you should use last_output = rnn_features[:, -1, :]