Error loading bidirectional LSTM model

Hi, I have successfully completed training a BiLSTM model which has been saved as model.model. When I loaded it using load_state_dict(torch.load()), it gives me an error says:

Unexpected key(s) in state_dict: “layer1.lstm.weight_ih_l1”, “layer1.lstm.weight_hh_l1”, “layer1.lstm.bias_ih_l1”, “layer1.lstm.bias_hh_l1”, “layer1.lstm.weight_ih_l1_reverse”, “layer1.lstm.weight_hh_l1_reverse”, “layer1.lstm.bias_ih_l1_reverse”, “layer1.lstm.bias_hh_l1_reverse”.

Any help is much appreciated

Maybe your trained model had two or more layers in the layer1.lstm (l1 is the second) and the model you’re loading it to only one?

Best regards

Thomas

1 Like