pytorch-slimming icon indicating copy to clipboard operation
pytorch-slimming copied to clipboard

[59, 64, 'M', 128, 128, 'M', 256, 256, 256, 256, 'M', 470, 239, 59, 40, 'M', 0, 3, 54, 483],有一层卷积数量是0,怎么解决呢

Open wuxiaolianggit opened this issue 3 years ago • 4 comments

大神您好,我在进行prune模型时,出现[59, 64, 'M', 128, 128, 'M', 256, 256, 256, 256, 'M', 470, 239, 59, 40, 'M', 0, 3, 54, 483],有一层卷积数量是0,然后就报错了,怎么解决呢?

[59, 64, 'M', 128, 128, 'M', 256, 256, 256, 256, 'M', 470, 239, 59, 40, 'M', 0, 3, 54, 483] Traceback (most recent call last): File "prune.py", line 111, in newmodel = vgg(cfg=cfg) File "/home/wxl/temp/pytorch-slimming/vgg.py", line 13, in init self.feature = self.make_layers(cfg, True) File "/home/wxl/temp/pytorch-slimming/vgg.py", line 30, in make_layers conv2d = nn.Conv2d(in_channels, v, kernel_size=3, padding=1, bias=False) File "/home/wxl/project/py36/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 330, in init False, pair(0), groups, bias, padding_mode) File "/home/wxl/project/py36/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 46, in init self.reset_parameters() File "/home/wxl/project/py36/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 49, in reset_parameters init.kaiming_uniform(self.weight, a=math.sqrt(5)) File "/home/wxl/project/py36/lib/python3.6/site-packages/torch/nn/init.py", line 314, in kaiming_uniform_ fan = _calculate_correct_fan(tensor, mode) File "/home/wxl/project/py36/lib/python3.6/site-packages/torch/nn/init.py", line 283, in _calculate_correct_fan fan_in, fan_out = _calculate_fan_in_and_fan_out(tensor) File "/home/wxl/project/py36/lib/python3.6/site-packages/torch/nn/init.py", line 215, in _calculate_fan_in_and_fan_out receptive_field_size = tensor[0][0].numel() IndexError: index 0 is out of bounds for dimension 0 with size 0 @ @ @foolwood

wuxiaolianggit avatar Jan 06 '21 07:01 wuxiaolianggit

@wuxiaolianggit 你好 我在prune ratio太高時也會遇到一樣的問題。 請問你後來怎麼解決的?

mpyh12345 avatar Dec 06 '22 07:12 mpyh12345

I have the same problem. Has it been solved?

XDUqinian avatar Apr 04 '23 11:04 XDUqinian

lower the threshold, for example 0.7 -> 0.5

uptownfunkmars avatar Apr 23 '23 01:04 uptownfunkmars

Thank you.However, I found that this problem may be caused by the fact that the pre-training model was not generated after sparsity training during pruning.

XDUqinian avatar Apr 23 '23 02:04 XDUqinian