xhwNobody / yolov5_prune_sfp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

get_small_model.py出现维度不匹配

HandsLing opened this issue · comments

运行get_small_model.py的时候,在
File "get_small_model.py", line 242, in
small_model = get_small_model(model)
File "get_small_model.py", line 186, in get_small_model
small_model.load_state_dict(small_state_dict)
File "/home/ctgai/anaconda3/envs/taco/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1052, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for Small_Model:
size mismatch for neck_self.conv1.conv.weight: copying a param with shape torch.Size([512, 716, 1, 1]) from checkpoint, the shape in current model is torch.Size([358, 716, 1, 1]).
size mismatch for neck_self.conv1.bn.weight: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([358]).
size mismatch for neck_self.conv1.bn.bias: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([358]).
size mismatch for neck_self.conv1.bn.running_mean: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([358]).
加载的模型是用的train_prune_sfp.py训练得到的模型,请问这是哪里的问题呢?

我的也是,这个咋解决啊 @HandsLing

@xhwNobody

需要对代码进行修改,统一small_model网络结构和修剪后参数的维度

@xhwNobody

需要对代码进行修改,统一small_model网络结构和修剪后参数的维度

请问您能展开说说么,我也遇到了这样的问题

请问你们解决了这个问题嘛,我也遇到了这个问题不知道怎么解决

各位大佬,如何解决的? 怎么改,来点详细说明啊。

大佬,这个咋解决啊
@xhwNobody