midasklr / yolov5prune

553 stars 113 forks source link

conv剪枝 percent超过10%就报错 #115

Open Tristesse-stk opened 2 years ago

Tristesse-stk commented 2 years ago

如题,本人使用第四个剪枝方法,训练完之后在剪枝的时候设置的percent只要超过10%就会报错 报错如下: Exception has occurred: IndexError index 0 is out of bounds for dimension 0 with size 0 File "D:\Python\yolov5prune-v5.0\models\common.py", line 37, in init self.conv = nn.Conv2d(c1, c2, k, s, autopad(k, p), groups=g, bias=False) File "D:\Python\yolov5prune-v5.0\models\pruned_common.py", line 34, in init self.cv2 = Conv(cv1in, cv2out, 1, 1) File "D:\Python\yolov5prune-v5.0\models\yolo.py", line 710, in parse_prunedmodel m = nn.Sequential([m(args) for _ in range(n)]) if n > 1 else m(*args) # module File "D:\Python\yolov5prune-v5.0\models\yolo.py", line 250, in init self.model, self.save, self.from_to_map = parse_pruned_model(self.maskbndict, deepcopy(self.yaml), ch=[ch]) # model, savelist File "D:\Python\yolov5prune-v5.0\prune_convbn.py", line 513, in test_prune pruned_model = ModelPruned(maskbndict=maskmergedict, cfg=pruned_yaml, ch=3).cuda() File "D:\Python\yolov5prune-v5.0\prune_convbn.py", line 885, in test_prune(opt.data,

查了下是c2=0的缘故。 但是我看您的剪枝比例可以达到78%,为什么我的比例这么小就会报错呢?

Zhengzhiyang0000 commented 1 year ago

你好,请问你解决这个问题了吗?我在裁剪时也是遇到这个问题