ssd-pytorch icon indicating copy to clipboard operation
ssd-pytorch copied to clipboard

预测是报错Error(s) in loading state_dict for SSD:

Open will-qzq opened this issue 4 years ago • 6 comments

预测时报错:Error(s) in loading state_dict for SSD:

will-qzq avatar Mar 13 '21 06:03 will-qzq

具体的

bubbliiiing avatar Mar 13 '21 15:03 bubbliiiing

具体的

File "/home/ssd-pytorch-master/predict.py", line 12, in ssd = SSD() File "/home/ssd-pytorch-master/ssd.py", line 54, in init self.generate() File "/home/ssd-pytorch-master/ssd.py", line 81, in generate model.load_state_dict(torch.load(self.model_path, map_location=device)) File "/root/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 847, in load_state_dict self.class.name, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for SSD:

will-qzq avatar Mar 13 '21 18:03 will-qzq

具体的

RuntimeError: Error(s) in loading state_dict for SSD: size mismatch for conf.0.weight: copying a param with shape torch.Size([16, 512, 3, 3]) from checkpoint, the shape in current model is torch.Size([20, 512, 3, 3]). size mismatch for conf.0.bias: copying a param with shape torch.Size([16]) from checkpoint, the shape in current model is torch.Size([20]). size mismatch for conf.1.weight: copying a param with shape torch.Size([24, 1024, 3, 3]) from checkpoint, the shape in current model is torch.Size([30, 1024, 3, 3]). size mismatch for conf.1.bias: copying a param with shape torch.Size([24]) from checkpoint, the shape in current model is torch.Size([30]). size mismatch for conf.2.weight: copying a param with shape torch.Size([24, 512, 3, 3]) from checkpoint, the shape in current model is torch.Size([30, 512, 3, 3]). size mismatch for conf.2.bias: copying a param with shape torch.Size([24]) from checkpoint, the shape in current model is torch.Size([30]). size mismatch for conf.3.weight: copying a param with shape torch.Size([24, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([30, 256, 3, 3]). size mismatch for conf.3.bias: copying a param with shape torch.Size([24]) from checkpoint, the shape in current model is torch.Size([30]). size mismatch for conf.4.weight: copying a param with shape torch.Size([16, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([20, 256, 3, 3]). size mismatch for conf.4.bias: copying a param with shape torch.Size([16]) from checkpoint, the shape in current model is torch.Size([20]). size mismatch for conf.5.weight: copying a param with shape torch.Size([16, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([20, 256, 3, 3]). size mismatch for conf.5.bias: copying a param with shape torch.Size([16]) from checkpoint, the shape in current model is torch.Size([20]).

will-qzq avatar Mar 16 '21 16:03 will-qzq

num_classes还是classes_path没修改好噢

bubbliiiing avatar Mar 25 '21 11:03 bubbliiiing

num_classes还是classes_path没修改好噢

问题解决,谢谢

will-qzq avatar Mar 25 '21 13:03 will-qzq

怎么解决的兄弟,我跟你一样的问题

Rycbar7 avatar Jun 11 '24 07:06 Rycbar7