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

Loss function #11

Closed
HamzaLinge opened this issue May 28, 2020 · 3 comments
Closed

Loss function #11

HamzaLinge opened this issue May 28, 2020 · 3 comments
Labels
good first issue Good for newcomers question Further information is requested

Comments

@HamzaLinge
Copy link

@viplix3 Thank you for your work,

  • I would like to know which loss function do you use ?

  • Is it possible to add another function and where ?

@viplix3
Copy link
Owner

viplix3 commented May 29, 2020

TL;DR
What loss function is currently being used?
For regression: Mean Squared error
For classification: Sigmoid cross-entropy

Is it possible to use other loss functions?
Obviously. Some suggestions...
For regression: Huber Loss (smooth L1 loss), likes of GIoU, DIoU etc.
For classification: I don't think so changing this can help much, sigmoid cross entropy works fine.

@baghdadhamdoud how the YOLO algorithm works is, it tries training a model which can do both, regression and classification simultaneously.
What is even the sense of doing two completely unrelated tasks simultaneously you ask?
Well, to detect where a particular object is in an image, we first need to tell if there even is an object in an image. This is where the classification part comes in.

THE CLASSIFICATION
YOLO gives a certain score to each box. Teaching a model to differentiate between an object and background can be treated as a classification task, where the two classes will be
Class 1 - Yes, some object is present.
Class 2 - No, no object is present.

Once you've identified that there is some object present, I think you would probably want to know what that object is. You don't want to pet a cat thinking it is a dog, no, NO! And this my friend is where another classification loss comes in and it tries to teach the model if there is an object present, what that object is.

THE REGRESSION
If you're still reading the crap I have been blurting out about the obvious things, I believe you really want to know how regression works, and I'll tell ya.
See, YOLO is an object detection algorithm, if we don't tell where the said object is present, it won't really be object detection. So, to get the coordinates of bounding boxes, YOLO uses regression. It tries to teach the model to predict the offsets of the mid-point of the predicted box w.r.t. some grids and along with it, the scaling factors of an anchor (an assumption made by us humans of how the box should be like), factors by which some said anchor should be stretched or squished to get a tight bounding box in the prediction.

@HamzaLinge
Copy link
Author

I thank you very much @viplix3 , i understand more how object detection works in YOLO.

Now i would to know, is it possible to use Focal Loss Function ?
It would be interesting to use it in view of what it can bring, it can solve the problem of class imbalance.

If it is possible, how in your repo ?

@viplix3
Copy link
Owner

viplix3 commented May 31, 2020

Not the actual focal loss, but a special case of focal loss has been implemented and is available in the repo, as pointed out in issue #10
The catch is, not a lot of testing has been done. You can follow this link for the exact code.

@viplix3 viplix3 added good first issue Good for newcomers question Further information is requested labels May 31, 2020
@viplix3 viplix3 pinned this issue May 31, 2020
@viplix3 viplix3 closed this as completed Apr 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants