Eric-mingjie / network-slimming

Network Slimming (Pytorch) (ICCV 2017)
MIT License
907 stars 214 forks source link

ZeroDivisionError: float division by zero #14

Open akb0787 opened 5 years ago

akb0787 commented 5 years ago

hey Eric. i got this error during pruning , can you suggest me how should i handle it. Thanks

Traceback (most recent call last): File "vggprune.py", line 128, in newmodel = vgg(cfg=cfg) File "/home/ustc/akb/network-slimming/models/vgg.py", line 22, in init self.feature = self.make_layers(cfg, True) File "/home/ustc/akb/network-slimming/models/vgg.py", line 39, in make_layers conv2d = nn.Conv2d(in_channels, v, kernel_size=3, padding=1, bias=False) File "/home/ustc/anaconda2/lib/python2.7/site-packages/torch/nn/modules/conv.py", line 297, in init False, _pair(0), groups, bias) File "/home/ustc/anaconda2/lib/python2.7/site-packages/torch/nn/modules/conv.py", line 38, in init self.reset_parameters() File "/home/ustc/anaconda2/lib/python2.7/site-packages/torch/nn/modules/conv.py", line 44, in reset_parameters stdv = 1. / math.sqrt(n) ZeroDivisionError: float division by zero

Eric-mingjie commented 5 years ago

Which prune ratio are you using? This could happen if you set prune ratio to be large where some layers could get zero channels left.

akb0787 commented 5 years ago

i am using default ratio of 0.7 on cifar10 for vgg19.

Eric-mingjie commented 5 years ago

Did your train your vgg model with sparsity?

akb0787 commented 5 years ago

yes i did, and i varied prune ratio but no effect.

Eric-mingjie commented 5 years ago

So you try prune ratio less than 0.7 and still does not work? Maybe you can train a second vgg model and see if it still does not work.