jiangtaoxie / fast-MPN-COV

@CVPR2018: Efficient unrolling iterative matrix square-root normalized ConvNets, implemented by PyTorch (and code of B-CNN,Compact bilinear pooling etc.) for training from scratch & finetuning.
http://peihuali.org/iSQRT-COV/index.html
MIT License
270 stars 56 forks source link

RuntimeError: Error(s) in loading state_dict for DataParallel: #5

Closed ray-lee-94 closed 5 years ago

ray-lee-94 commented 5 years ago

When I fine-tuned the mpncovresnet50 in second stage, the error occured.

loading checkpoint 'Finetune-c9-mpncovresnet50-MPNCOV-reproduce-lr0.001-bs40/checkpoint.pth.tar' Traceback (most recent call last): File "main.py", line 436, in main() File "main.py", line 179, in main model.load_state_dict(checkpoint['state_dict']) File "/home/wen/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 719, in load_state_dict self.class.name, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for DataParallel: Missing key(s) in state_dict: "module.representation.conv_dr_block.0.weight", "module.representation.conv_dr_block.1.weight", "module.representation.conv_dr_block.1.bias", "module.representation.conv_dr_block.1.running_mean", "module.representation.conv_dr_block.1.running_var". Unexpected key(s) in state_dict: "module.features.8.weight", "module.features.9.weight", "module.features.9.bias", "module.features.9.running_mean", "module.features.9.running_var", "module.features.9.num_batches_tracked".

two_stage_finetune.txt this is my config.

ray-lee-94 commented 5 years ago

I delete the "--pretrained" on the popurse to reduce the dimension to 256. Because my dataset is small.

jiangtaoxie commented 5 years ago

Hi, @VCBE123 That's right, if you delete the "--pretrained" in second stage, it'll get a different base model.

ray-lee-94 commented 5 years ago

If i want to use the pretrained weight of resnet, But i alse need the dimension reduce.What should i do?

jiangtaoxie commented 5 years ago

@VCBE123 Do you want to use dimension reduction + global averge pooling?
if so, you can modify the src/representation/GAvP.py to add a dimension reduction block like MPNCOV.py does. Then choose image_representation=GAvP in shell. if not, you can remove the condition part in this line of main.py