Lam1360 / YOLOv3-model-pruning

在 oxford hand 数据集上对 YOLOv3 做模型剪枝(network slimming)
MIT License
1.67k stars 431 forks source link

剪枝后运行模型出错 #78

Closed dengfenglai321 closed 4 years ago

dengfenglai321 commented 4 years ago

你好 我运行test_prun.py得到剪枝的模型 然后运行 python train.py --model_def config/prune_yolov3-hand.cfg -pre checkpoin ts/prune_0.85_yolov3_ckpt_50_12291908.pth prune_0.85_yolov3_ckpt_50_12291908.pthweights剪枝得到的模型 报错了,错误信息如下:

请问是哪里除了问题呢

File "train.py", line 74, in model.load_state_dict(torch.load(opt.pretrained_weights)) File "/home/cendelian/anaconda3/envs/pytorch_tf/lib/python3.6/site-packages/torch/nn/modules/module.py", line 845, in load_state_dict self.class.name, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for Darknet: size mismatch for module_list.0.conv_0.weight: copying a param with shape torch.Size([30, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([19, 3, 3, 3]). size mismatch for module_list.0.batch_norm_0.weight: copying a param with shape torch.Size([30]) from checkpoint, the shape in current model is torch.Size([19]). size mismatch for module_list.0.batch_norm_0.bias: copying a param with shape torch.Size([30]) from checkpoint, the shape in current model is torch.Size([19]). size mismatch for module_list.0.batch_norm_0.running_mean: copying a param with shape torch.Size([30]) from checkpoint, the shape in current model is torch.Size([19]). size mismatch for module_list.0.batch_norm_0.running_var: copying a param with shape torch.Size([30]) from checkpoint, the shape in current model is torch.Size([19]). size mismatch for module_list.1.conv_1.weight: copying a param with shape torch.Size([64, 30, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 19, 3, 3]). size mismatch for module_list.2.conv_2.weight: copying a param with shape torch.Size([28, 64, 1, 1]) from checkpoint, the shape in current model is torch.Size([25, 64, 1, 1]). size mismatch for module_list.2.batch_norm_2.weight: copying a param with shape torch.Size([28]) from checkpoint, the shape in current model is torch.Size([25]). size mismatch for module_list.2.batch_norm_2.bias: copying a param with shape torch.Size([28]) from checkpoint, the shape in current model is torch.Size([25]). size mismatch for module_list.2.batch_norm_2.running_mean: copying a param with shape torch.Size([28]) from checkpoint, the shape in current model is torch.Size([25]). size mismatch for module_list.2.batch_norm_2.running_var: copying a param with shape torch.Size([28]) from checkpoint, the shape in current model is torch.Size([25]). size mismatch for module_list.3.conv_3.weight: copying a param with shape torch.Size([64, 28, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 25, 3, 3]).

cc-sketch commented 3 years ago

请问楼主解决了该问题嘛