The confusing positional arguments in the definition of focal loss
See original GitHub issueHi, I think you have a small but quite critical mistake in: https://github.com/qubvel/segmentation_models/blob/ba5cfca2b30be14050304096dba2fe0963b588e3/segmentation_models/losses.py#L238
In here, the arguments aboved are passed to the function below in the form of positional arguments: https://github.com/qubvel/segmentation_models/blob/ba5cfca2b30be14050304096dba2fe0963b588e3/segmentation_models/base/functional.py#L286
Here comes the confusing part. I think the value of alpha
which we expect it to be, is replaced with the value of gamma
. The same thing happens to gamma
, too. But I’m not 100% certain about this.
If anyone sees this issue, I hope you can give a clear answer.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
The alpha parameter of focal loss - Cross Validated
I want to use a weighted focal loss for my imbalanced object detection problem. L=−α(1−ˆp)γlog(ˆp), ˆp={p,if y=11−p,otherwise.
Read more >Understanding Categorical Cross-Entropy Loss, Binary Cross ...
Focal loss is a Cross-Entropy Loss that weighs the contribution of each sample to the loss based in the classification error.
Read more >Understanding Focal Loss in 5 mins | Medium | VisionWizard
Focal loss is used to address the issue of the class imbalance problem. A modulation term applied to the Cross-Entropy loss function, make...
Read more >How to Use Class Weights with Focal Loss in PyTorch for ...
Focal loss automatically handles the class imbalance, hence weights are not required for the focal loss. The alpha and gamma factors handle ...
Read more >Focal Loss in Object Detection - Analytics Vidhya
So Focal Loss reduces the loss contribution from easy examples and increases the importance of correcting misclassified examples.) So, let's ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @LeeJayHui Thanks for pointing out about mistake in positional arguments! Can you create a PR to fix it? About
alpha
coefficient… It not clear (for me) from paper is it should bealpha
and(1 - alpha)
or justalpha
. Because in paper it is noted asalpha_t
without description.You are absolutely right, there are a lot of ways for improvement! If you have any ideas you can open a Pull Request and propose changes!