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

ERROR:ZeroDivisionError: division by zero #18

Open
RumengYi opened this issue Sep 27, 2019 · 1 comment
Open

ERROR:ZeroDivisionError: division by zero #18

RumengYi opened this issue Sep 27, 2019 · 1 comment

Comments

@RumengYi
Copy link

how can i slove this problem when i run python train.py ../config/pascal_unet_res18_scse.yaml?
Traceback (most recent call last):
File "train.py", line 159, in
loss = loss_fn(preds, labels)
File "/home/yirumeng/anaconda3/envs/Pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(*input, **kwargs)
File "/home/yirumeng/code/CAM/pytorch-segmentation-master/src/losses/multi/init.py", line 26, in forward
loss = self.criterion(preds, labels)
File "/home/yirumeng/anaconda3/envs/Pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(*input, **kwargs)
File "/home/yirumeng/code/CAM/pytorch-segmentation-master/src/losses/multi/lovasz_loss.py", line 77, in forward
total_loss += lovasz_softmax_flat(prb, lbl, self.ignore_index, self.only_present)
File "/home/yirumeng/code/CAM/pytorch-segmentation-master/src/losses/multi/lovasz_loss.py", line 56, in lovasz_softmax_flat
return total_loss / cnt
ZeroDivisionError: division by zero

@carlodizon03
Copy link

try:
    z = total_loss / cnt
except ZeroDivisionError:
    z = 0
return z

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

2 participants