Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wuxiaolianggit opened this issue Jan 6, 2021 · 4 comments

Comments

@wuxiaolianggit
Copy link

大神您好,我在进行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

@mpyh12345
Copy link

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

@XDUqinian
Copy link

I have the same problem. Has it been solved?

@uptownfunkmars
Copy link

uptownfunkmars commented Apr 23, 2023

lower the threshold, for example 0.7 -> 0.5

@XDUqinian
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants