YINYIPENG-EN/Pruning_for_YOLOX

AttributeError: module 'torch_pruning' has no attribute 'prune_conv'

Opened this issue · 12 comments

您好,我明明安装了pip install torch-pruning,但是还是再pruning_plan = DG.get_pruning_plan((model.backbone.backbone.dark2)[0].dconv.conv, tp.prune_conv, idxs=pruning_idxs)这个函数运行时候出现
AttributeError: module 'torch_pruning' has no attribute 'prune_conv'的错误,请问是什么原因呢

你是不是没安装对呀?是pip install torch_pruning,不是torch-pruning

你是没安装对呀?是pip install torch_pruning,不是torch-pruning

其实我两个都试了一遍 还是不行,它好像安装到别的地方了 ,但是我把库文件复制过来了,按理说也不该出问题的啊

那你就是没正确安装上呗,你试试在终端或者用conda激活你的环境然后安装,可以加上版本进行安装pip install torch_pruning==0.2.7

剪枝后 有转onnx的方法嘛,转onnx出现了size mismatch for backbone.backbone.stem.conv.conv.weight: copying a param with shape torch.Size([10, 12, 3, 3]) from checkpoint, the shape in current model is torch.Size([16, 12, 3, 3]).问题

/

剪枝后我没有转onnx,你这个是出现了维度不匹配的问题。首先你在转onnx或者推理的时候不需要再用model=YOLOX()进行实例化,可以直接用model = torch.load('你剪枝后的权重')进行模型实例化,看看这里对不对,还有就是你传入的shape以及类别数量是否正确 | | 尹以鹏 | | @.*** | On 7/21/2022 @.> wrote: 剪枝后 有转onnx的方法嘛,转onnx出现了size mismatch for backbone.backbone.stem.conv.conv.weight: copying a param with shape torch.Size([10, 12, 3, 3]) from checkpoint, the shape in current model is torch.Size([16, 12, 3, 3]).问题 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.>

但是如何能够不加载YoloBody模型,直接用torch.load实例化呢

要是转onnx的话 基本上就不能微调了是嘛,另外如果想进行通道剪枝 该怎么做呢

大佬,有没有BN层剪枝的代码啊

感觉还要稀疏化训练,我再看看,自己写了一部分