Hi,
I have been transforming a Keras-written code into a PyTorch code and encountered a problem that seems a bit tricky for me(Keras model here 1). I’ve checked every single layer for Keras&Pytorch for the model and before the LSTM layer, all of the outputs are same when the weights initialization are same for both of the framework(manually set it).
However, the LSTM layer acts differently even though the same weight is given for both of the models. Below is a code for Keras
conv_lstm = LSTM(64)(conv_reshape)

and below is the code for Pytorch
def __init__(...):
    ...
    self.LSTM = nn.LSTM(192, 64, 1, batch_first = True)
    ....

def forward(self, ...):
    ....
    lstm, _ = self.LSTM(output)
    lstm = lstm[:,-1,:]
    ....

If anyone has any idea about this, please help me out! Thanks in advance.