THU-MIG / torch-model-compression

针对pytorch模型的自动化模型结构分析和修改工具集,包含自动分析模型结构的模型压缩算法库

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

关于resnet和自建模型prune时遇到的相同报错

EricBlaine007 opened this issue · comments

commented

前辈您好,最近学习了您ACNet、ResRep、RepVGG几篇文章,您真的有非凡的创造力!但我使用您在examples中给出的prune.py示例对resnet56和自己模型的压缩中遇到了相同的报错,可以向您请教下吗?
(1)对resnet56压缩时的报错如下:
Traceback (most recent call last):
File "/home3/xxx/torch-model-compression-main/examples/torchslim/pytorch_cifar/prune.py", line 294, in
solver.run()
File "/home3/xxx/torch-model-compression-main/torchslim/slim_solver.py", line 790, in run
self.run_hook(self.iteration_end_hook)
File "/home3/xxx/torch-model-compression-main/torchslim/slim_solver.py", line 660, in run_hook
function(self)
File "/home3/xxx/torch-model-compression-main/torchslim/pruning/resrep.py", line 827, in after_iteration_hook
current_graph.build_graph(graph_inputs)
File "/home3/xxx/torch-model-compression-main/torchpruner/graph.py", line 622, in build_graph
operator_dict[operator].fill_shape()
File "/home3/xxx/torch-model-compression-main/torchpruner/operator/operator.py", line 191, in fill_shape
+ "'"
RuntimeError: Fail to predict the shape on operator name: 'self.bn1.BatchNormalization', type: 'BatchNormalization'
(2)对自己构建模型的报错如下:
Traceback (most recent call last):
File "/home3/xxx/.pycharm_helpers/pydev/pydevd.py", line 1434, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/home3/xxx/.pycharm_helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home3/gaoya/torch-model-compression-main/examples/torchslim/pytorch_cifar/prune.py", line 203, in
solver.run()
File "/home3/xxx/torch-model-compression-main/torchslim/slim_solver.py", line 790, in run
self.run_hook(self.iteration_end_hook)
File "/home3/xxx/torch-model-compression-main/torchslim/slim_solver.py", line 660, in run_hook
function(self)
File "/home3/xxx/torch-model-compression-main/torchslim/pruning/resrep.py", line 827, in after_iteration_hook
current_graph.build_graph(graph_inputs)
File "/home3/xxx/torch-model-compression-main/torchpruner/graph.py", line 622, in build_graph
operator_dict[operator].fill_shape()
File "/home3/xxx/torch-model-compression-main/torchpruner/operator/operator.py", line 191, in fill_shape
+ "'" RuntimeError: Fail to predict the shape on operator name: 'self.net_encoder.encoder_inp_lnorm.BatchNormalization', type: 'BatchNormalization'
我的理解是在构建静态图时无法正确预测BN层中节点的形状,我的系统是Linux,torch==1.13.1,torchvision==0.14.1,可以向您请教下关于这个问题吗?