ptrblck:

parameters


Thanks for the reply ptrblck!
So, the code I wrote for matching the weights are as below,
model.LSTM.weight_ih_l0.data = torch.nn.Parameter(torch.FloatTensor(np.transpose(weights[28])).contiguous().to(device))
model.LSTM.weight_hh_l0.data = torch.nn.Parameter(torch.FloatTensor(np.transpose(weights[29])).contiguous().to(device))

model.LSTM.bias_ih_l0.data = torch.from_numpy(weights[30]).to(device)
model.LSTM.bias_hh_l0.data = torch.from_numpy(weights[30]).to(device)

Basically, the weights from Keras LSTM are in the list ‘weights’, and as Keras has only one bias(the same shape with both of the biases in the Pytorch LSTM), the same weights are given for both of the biases.
After running the code above, when I checked the weights for the model by running ‘model.LSTM.weight~ or model.LSTM.bias~’, all the weights seem to be properly set. If you have any idea where this difference of outputs coming from, please let me know!
Thanks