talebolano / yolov3-network-slimming

yolov3 network slimming剪枝的一种实现
344 stars 93 forks source link

division by zero(稀疏化训练时) #9

Open zhengshoujian opened 5 years ago

zhengshoujian commented 5 years ago

在稀疏化训练的时候发生了一下错误 zweistein@zweistein-System-Product-Name:~/桌面/yolov3-network-slimming$ python sparsity_train.py -sr --s 0.1 --image_folder cfg/coco.data --cfg cfg/yolov3.cfg --weights yolov3.weights load network done! load weightsfile done! /usr/local/lib/python3.5/dist-packages/skimage/transform/_warps.py:110: UserWarning: Anti-aliasing will be enabled by default in skimage 0.15 to avoid aliasing artifacts when down-sampling images. warn("Anti-aliasing will be enabled by default in skimage 0.15 to " /usr/local/lib/python3.5/dist-packages/skimage/transform/_warps.py:110: UserWarning: Anti-aliasing will be enabled by default in skimage 0.15 to avoid aliasing artifacts when down-sampling images. warn("Anti-aliasing will be enabled by default in skimage 0.15 to " /usr/local/lib/python3.5/dist-packages/torch/nn/modules/upsampling.py:122: UserWarning: nn.Upsampling is deprecated. Use nn.functional.interpolate instead. warnings.warn("nn.Upsampling is deprecated. Use nn.functional.interpolate instead.") Traceback (most recent call last): File "sparsity_train.py", line 154, in train() File "sparsity_train.py", line 100, in train loss = model(imgs, targets) File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(*input, kwargs) File "/home/zweistein/桌面/yolov3-network-slimming/yolomodel.py", line 347, in forward x, losses = self.module_list[i][0](x, targets) File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(input, kwargs) File "/home/zweistein/桌面/yolov3-network-slimming/yolomodel.py", line 107, in forward precision = float(nCorrect / nProposals) ZeroDivisionError: division by zero 请问应该如何解决

nepulhl commented 5 years ago

您好,我遇到了跟您相同的问题,请问您的问题解决了吗

nepulhl commented 5 years ago

@zhengshoujian 我已经解决了这个问题 将yolomodel.py第107行 precision = float(nCorrect / nProposals) 修改为 if nProposals: precision = float(nCorrect / nProposals) elif nCorrect: precision = 0 else: precision = 1

zhengshoujian commented 5 years ago

@nepulhl 谢谢!

lizhaokun commented 5 years ago

在nProposals后加一个很小的值也是可以的,是为了避免出现nProposals做除数有等于0的情况的发生