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

divided by 0 error #541

Closed
AlexWang1900 opened this issue Jul 28, 2020 · 3 comments
Closed

divided by 0 error #541

AlexWang1900 opened this issue Jul 28, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@AlexWang1900
Copy link
Contributor

Before submitting a bug report, please be aware that your issue must be reproducible with all of the following, otherwise it is non-actionable, and we can not help you:

If this is a custom dataset/training question you must include your train*.jpg, test*.jpg and results.png figures, or we can not help you. You can generate these with utils.plot_results().

🐛 Bug

in utils.py line 345:

elif CIoU:  # https://github.com/Zzh-tju/DIoU-SSD-pytorch/blob/master/utils/box/box_utils.py#L47
                v = (4 / math.pi ** 2) * torch.pow(torch.atan(w2 / h2) - torch.atan(w1 / h1), 2)
                with torch.no_grad():
                    alpha = v / (1 - iou + v)   ### should add + 1e-16 to avoid alpha = NAN.
                return iou - (rho2 / c2 + v * alpha)  # CIoU

To Reproduce (REQUIRED)

it's hard to reproduce, I encounter it when I was trying some new target assigning methods..

Output:
alpha = Nan.

Expected behavior

alpha be a normal value between 0 - 1

Environment

If applicable, add screenshots to help explain your problem.

  • OS: [e.g. Ubuntu]
  • GPU [e.g. 2080 Ti]

Additional context

Add any other context about the problem here.
it's hard to reproduce, I encounter it when I was trying some new target assigning methods..

@AlexWang1900 AlexWang1900 added the bug Something isn't working label Jul 28, 2020
@AlexWang1900 AlexWang1900 changed the title divide by 0 error divided by 0 error Jul 28, 2020
@glenn-jocher
Copy link
Member

@AlexWang1900 ah, thanks for the bug report! It looks like c2 is already protected, so then alpha may be the only unprotected divide as you say. Yes we should add 1e-16 here. Would you like to submit a PR for this or I can include it in the next commit?

@glenn-jocher glenn-jocher added the TODO High priority items label Jul 28, 2020
@AlexWang1900
Copy link
Contributor Author

AlexWang1900 commented Jul 29, 2020 via email

AlexWang1900 added a commit to AlexWang1900/yolov5 that referenced this issue Jul 29, 2020
glenn-jocher added a commit that referenced this issue Jul 31, 2020
* fix #541 #542

* Update train.py

* Add Frelu

* Update activations.py

PEP8 and format updates for commonality with models.common.Conv()

* Update activations.py

Update case

* Update activations.py

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
@glenn-jocher
Copy link
Member

Issue resolved, removing TODO.

@glenn-jocher glenn-jocher removed the TODO High priority items label Aug 5, 2020
KMint1819 pushed a commit to KMint1819/yolov5 that referenced this issue May 12, 2021
* fix ultralytics#541 ultralytics#542

* Update train.py

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
KMint1819 pushed a commit to KMint1819/yolov5 that referenced this issue May 12, 2021
* fix ultralytics#541 ultralytics#542

* Update train.py

* Add Frelu

* Update activations.py

PEP8 and format updates for commonality with models.common.Conv()

* Update activations.py

Update case

* Update activations.py

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
BjarneKuehl pushed a commit to fhkiel-mlaip/yolov5 that referenced this issue Aug 26, 2022
* fix ultralytics#541 ultralytics#542

* Update train.py

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
BjarneKuehl pushed a commit to fhkiel-mlaip/yolov5 that referenced this issue Aug 26, 2022
* fix ultralytics#541 ultralytics#542

* Update train.py

* Add Frelu

* Update activations.py

PEP8 and format updates for commonality with models.common.Conv()

* Update activations.py

Update case

* Update activations.py

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants