HankYe / PAGCP

PAGCP for the compression of YOLOv5
GNU General Public License v3.0
111 stars 11 forks source link

问题咨询 #6

Closed douzi0248 closed 1 year ago

douzi0248 commented 1 year ago

你好,感谢开源,有个部分代码没有看明白,想咨询一下 def set_group(self, model): bottleneck_index = [2, 4, 6] self.groups = [[f'model[{i}].m[{n}].cv2.conv' for n in range(len(model.module[i].m if hasattr(model, 'module') else model[i].m))] + [ f'model[{i}].cv1.conv'] for i in bottleneck_index] 在sensitivity.py中这个函数的group是有什么意思, bottleneck_index 表示是要剪枝的层在model中的索引吗?模型在剪枝时时只剪枝这些层吗

HankYe commented 1 year ago

您好,感谢您对工作的关注。

  1. set_group函数的含义是为了抽取出在输出通道上有依赖关系的层,放入同一个group中,并评估整个group的重要性指标作为每个成员的重要性值。在剪枝过程中对于group中的层进行同步剪枝,并且遍历模型时遇到同一group的成员只进行一次剪枝;
  2. bottleneck_index是用于抽象出模型中满足上述定义的group成员,经过分析每个bottleneck中都存在一个group,所以通过bottleneck_index的方式简便的用for 循环遍历出模型中的所有group;
  3. 模型在剪枝时会剪所有可以剪的卷积层,不局限在这些group中。 希望上述回复能解答您的相关疑问。若仍有疑惑,欢迎进一步交流。
douzi0248 commented 1 year ago

嗯,明白了,谢谢回复