question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The confusing positional arguments in the definition of focal loss

See original GitHub issue

Hi, 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:closed
  • Created 4 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
qubvelcommented, Nov 18, 2019

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 be alpha and (1 - alpha) or just alpha. Because in paper it is noted as alpha_t without description.

0reactions
qubvelcommented, Nov 21, 2019

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found