salaniz / pytorch-gve-lrcn

PyTorch implementations for "Generating Visual Explanations" (GVE) and "Long-term Recurrent Convolutional Networks" (LRCN)
MIT License
92 stars 22 forks source link

Encountering Runtime error while trying to evaluate model #13

Closed CodeChef123 closed 1 year ago

CodeChef123 commented 4 years ago

Screenshot from 2020-03-02 14-04-22 `Arguments: data_path ./data checkpoint_path ./checkpoints log_step 10 num_workers 4 disable_cuda False cuda_device 0 torch_seed 11416326708069906744 model gve dataset cub pretrained_model None layers_to_truncate 1 sc_ckpt data/cub/sentence_classifier_ckpt.pth weights_ckpt None loss_lambda 0.2 embedding_size 1000 hidden_size 1000 num_epochs 50 batch_size 128 learning_rate 0.001 train False eval_ckpt checkpoints/lrcn-coco-D2020-02-25-T09-38-57-G0/ckpt-e50.pth

Preparing Data ... loading annotations into memory... Done (t=0.04s) creating index... index created!

Loading Model ... GVE( (word_embed): Embedding(3012, 1000, padding_idx=0) (linear1): Linear(in_features=8192, out_features=1000, bias=True) (lstm1): LSTM(1000, 1000, batch_first=True) (lstm2): LSTM(2200, 1000, batch_first=True) (linear2): Linear(in_features=1000, out_features=3012, bias=True) (sentence_classifier): SentenceClassifier( (word_embed): Embedding(3012, 1000, padding_idx=0) (lstm): LSTM(1000, 1000, batch_first=True) (linear): Linear(in_features=1000, out_features=200, bias=True) ) )

Loading Model Weights ... Traceback (most recent call last): File "main.py", line 63, in model.load_state_dict(model_dict) File "/home/devang/anaconda3/envs/gve-lrcn/lib/python3.7/site-packages/torch/nn/modules/module.py", line 777, in load_state_dict self.class.name, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for GVE: size mismatch for word_embed.weight: copying a param with shape torch.Size([24834, 1000]) from checkpoint, the shape in current model is torch.Size([3012, 1000]). size mismatch for linear1.weight: copying a param with shape torch.Size([1000, 4096]) from checkpoint, the shape in current model is torch.Size([1000, 8192]). size mismatch for lstm2.weight_ih_l0: copying a param with shape torch.Size([4000, 2000]) from checkpoint, the shape in current model is torch.Size([4000, 2200]). size mismatch for linear2.weight: copying a param with shape torch.Size([24834, 1000]) from checkpoint, the shape in current model is torch.Size([3012, 1000]). size mismatch for linear2.bias: copying a param with shape torch.Size([24834]) from checkpoint, the shape in current model is torch.Size([3012]). `

salaniz commented 1 year ago

The code has changed since the issue was opened. Please open a new issue if the issue persists.