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

Hi,I have a question about the loss compute? #207

Closed
BCWang93 opened this issue Apr 11, 2019 · 5 comments
Closed

Hi,I have a question about the loss compute? #207

BCWang93 opened this issue Apr 11, 2019 · 5 comments
Labels
enhancement New feature or request

Comments

@BCWang93
Copy link

In the 'compute_loss.py',I found this way to compute loss:
" k = 1 # nT / bs
if len(b) > 0:
pi = pi0[b, a, gj, gi] # predictions closest to anchors
tconf[b, a, gj, gi] = 1 # conf

        lxy += (k * 8) * MSE(torch.sigmoid(pi[..., 0:2]), txy[i])  # xy loss
        lwh += (k * 4) * MSE(pi[..., 2:4], twh[i])  # wh yolo loss
        # lwh += (k * 4) * MSE(torch.sigmoid(pi[..., 2:4]), twh[i])  # wh power loss
        lcls += (k * 1) * CE(pi[..., 5:], tcls[i])  # class_conf loss

    # pos_weight = FT([gp[i] / min(gp) * 4.])
    # BCE = nn.BCEWithLogitsLoss(pos_weight=pos_weight)
    lconf += (k * 64) * BCE(pi0[..., 4], tconf)  # obj_conf loss
loss = lxy + lwh + lconf + lcls"

the 'k' is what?And why do you multiply the number like '4,8,1',and the loss you compute is the all batch or the mean?Hope you reply!Thank you very much!

@BCWang93 BCWang93 added the enhancement New feature or request label Apr 11, 2019
@glenn-jocher
Copy link
Member

@BCWang93 these are very good questions. Unfortunately when we implemented the exact darknet loss function we got poor results during training, so we tried hyperparameter tuning, and the current loss constants you see here are what we found to produce the best results on coco training from scratch. The main changes are:

  • The loss multiples you see there, 8, 4, 64 etc.
  • The loss constant k that is applied to all losses. Some people believe this should be a function of the batch size, etc.
  • The classification loss is now CE rather than BCE as we found better results this way.
  • There is an IOU rejection constant of 0.10 in build_targets() which we found dramatically improved training results.
  • Image augmentation settings in datasets.py

We need to reexamine all of these and retune them ideally since there have been many changes since they were first set. I am hoping to start a dedicated issue on this topic soon. See #205 for more information.

Also beware, a low-mAP bug was fixed in the last couple days, I strongly encourage you to git clone a clean copy of the latest repo (or git pull) before doing any new training. See #197

@BCWang93
Copy link
Author

@BCWang93 these are very good questions. Unfortunately when we implemented the exact darknet loss function we got poor results during training, so we tried hyperparameter tuning, and the current loss constants you see here are what we found to produce the best results on coco training from scratch. The main changes are:

  • The loss multiples you see there, 8, 4, 64 etc.
  • The loss constant k that is applied to all losses. Some people believe this should be a function of the batch size, etc.
  • The classification loss is now CE rather than BCE as we found better results this way.
  • There is an IOU rejection constant of 0.10 in build_targets() which we found dramatically improved training results.
  • Image augmentation settings in datasets.py

We need to reexamine all of these and retune them ideally since there have been many changes since they were first set. I am hoping to start a dedicated issue on this topic soon. See #205 for more information.

Also beware, a low-mAP bug was fixed in the last couple days, I strongly encourage you to git clone a clean copy of the latest repo (or git pull) before doing any new training. See #197

Thanks for your reply! I will test it!Thanks!

@dsp6414
Copy link

dsp6414 commented Apr 12, 2019

The value of mAP is greater than 1.0.

image

@BCWang93
Copy link
Author

The value of mAP is greater than 1.0.

image

Hi,this result is in this implement?

@glenn-jocher
Copy link
Member

@dsp6414 those are not mAP values > 1 those are recall values. Can you supply your test images, .data, .cfg files, and trained model to reproduce the issue?

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

No branches or pull requests

3 participants