It seems correct to me. I’ve used the same code in one of my projects before (just different variables) and I got very close results with the PyTorch LSTM. May you please post your results and code when using the PyTorch LSTM?