eriklindernoren / Action-Recognition

Exploration of different solutions to action recognition in video, using neural networks implemented in PyTorch.
179 stars 74 forks source link

RuntimeError: Error(s) in loading state_dict for ConvLSTM: Missing key(s) in state_dict #24

Closed farazBhatti closed 4 days ago

farazBhatti commented 4 days ago

There seems to be a mismatch between pre-trained model and model written in code files.

RuntimeError: Error(s) in loading state_dict for ConvLSTM: Missing key(s) in state_dict: "lstm.lstm.weight_ih_l0_reverse", "lstm.lstm.weight_hh_l0_reverse", "lstm.lstm.bias_ih_l0_reverse", "lstm.lstm.bias_hh_l0_reverse", "output_layers.0.weight", "output_layers.0.bias", "output_layers.1.weight", "output_layers.1.bias", "output_layers.1.running_mean", "output_layers.1.running_var", "output_layers.3.weight", "output_layers.3.bias", "attention_layer.weight", "attention_layer.bias". Unexpected key(s) in state_dict: "lstm.final.0.weight", "lstm.final.0.bias", "lstm.final.1.weight", "lstm.final.1.bias", "lstm.final.1.running_mean", "lstm.final.1.running_var", "lstm.final.1.num_batches_tracked", "lstm.final.3.weight", "lstm.final.3.bias".

farazBhatti commented 4 days ago

A workaround this can be by loading partial model. replace : model.load_state_dict(torch.load(opt.checkpoint_model)) with: model.load_state_dict(torch.load(opt.checkpoint_model), strict = False)

`

# Define model and load model checkpoint
model = ConvLSTM(num_classes=len(labels), latent_dim=opt.latent_dim)
model.to(device)
model.load_state_dict(torch.load(opt.checkpoint_model), strict = False) #model.load_state_dict(state_dict, strict=False)

model.eval()`