Could you explain, what dropout=0.2 and recurrent_dropout=0.2 do in your Keras model?
It seems that you are using a single F.dropout on the outputs of both LSTM layers.


From the keras docs, dropout is for the linear transformation of the inputs and recurrent_dropout is for the linear transformation of the recurrent states.
I’m guessing keras dropout masks the inputs, hence that should simply be implemented by adding a F.dropout layer before each LSTM in PyTorch (I’ve mistakenly added them at the outputs, I’ll change it right away)
I’m not able to understand how to implement the recurrent_dropout part in PyTorch, which masks the connections between the recurrent units. Is it possible that absence of this particular dropout is the only reason why the PyTorch model is not learning while Keras one is?


Also, since you are using the functional dropout API, you should pass the training=self.training argument to disable it during validation. 


Oh yes, my bad. I’ll change it right away.
Thanks a lot!