剪枝时前面的层数正常,最后几层在对齐masks same size时报错
EricBlaine007 opened this issue · comments
您好,我在剪枝自己写的模型时前面大部分层的剪枝都是正常的,但是最后某一层出现了如下问题:
Cutting layer is: self.channel_down.compactor
AAAAAAAAAAAAAA [32, 128, 1, 400] # 以下两行是我打印出来的 mask_dict[name], return_masks[name]
BBBBBBBBBBBBBB [400, 1, 128, 32]
Traceback (most recent call last):
File "/.../torch-model-compression-main/examples/torchslim/pytorch_cifar/prune.py", line 208, in
solver.run()
File "/.../torch-model-compression-main/torchslim/slim_solver.py", line 792, in run
self.run_hook(self.iteration_end_hook)
File "/.../torch-model-compression-main/torchslim/slim_solver.py", line 662, in run_hook
function(self)
File "/.../torch-model-compression-main/torchslim/pruning/resrep.py", line 838, in after_iteration_hook
self.config["min_channels"],
File "/.../torch-model-compression-main/torchslim/pruning/resrep.py", line 722, in prune_model
"conv.weight", index=min_index, dim=0
File "/.../torch-model-compression-main/torchpruner/graph.py", line 342, in cut_analysis
return current_module.terminal_node.cut_analysis(index, dim)
File "/.../torch-model-compression-main/torchpruner/graph.py", line 246, in cut_analysis
return self.cut_analysis_with_mask(mask)
File "/.../torch-model-compression-main/torchpruner/graph.py", line 292, in cut_analysis_with_mask
[mask_dict[name], return_masks[name]]
File "/.../torch-model-compression-main/torchpruner/mask_utils.py", line 70, in combine_mask
raise RuntimeError("The input mask size should be same")
RuntimeError: The input mask size should be same
Process finished with exit code 1
我屏蔽了一些name,发现该层中很多name都是报相同的错误,可以向您请教下该如何解决吗