shivin7:

I guess the only solution is to manually write the LSTM cell then. However, shouldn’t absence of such a dropout be responsible for overfitting at max?


That might be the case and I agree that something else might create the issue.
In the Keras implementation you are using return_sequences=False.
Based on the docs, it seems that this LSTM will only return the output of the last timestep.
In your PyTorch implementation you are reshaping the output of self.lstmLayer2 via:
x = x.view(x.shape[1], x.shape[2])

which is not using the last timestep, but the complete sequence.
That being said, I think the reshaping in general might be wrong.
The last pooling layer will return an activation in the shape [batch_size, channels, seq_len].
Since the nn.LSTM will accept an input of [seq_len, batch_size, nb_features] by default (if batch_first=False).
It seems you would like to permute the activation here:
x = x.view(x.shape[2], x.shape[0], x.shape[1])

which won’t work, since you are interleaving the signal.
Use x = x.permute(2, 0, 1) instead to permute the dimensions.
The same applies for the output of self.lstmLayer2.
Let me know, if that helps.