You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found this stale issue that touches upon this same topic. #671
Currently the losses.FocalLoss interface doesn't allow to pass probabilities (unlike other Losses that have both a probs and logits implementation) and expects logits, which then are activated by a sigmoid in the losses._functional.focal_loss_with_logits function. Since sigmoid can only work in a binary case, the loss is calculated per class in binary fashion and then summed.
Interestingly, there's also a softmax version in losses._functional.softmax_focal_loss_with_logits and it's more similar to how the FocalLoss works in segmentation_models for tensorflow/keras. In this case, the loss wouldn't need to be calculated per class in the wrapper.
Is there any reason on why Focal Loss is calculated with this function and using sigmoid? Should the results be equivalent to softmax somehow? I would think softmax would be a more appropiate solution for the multiclass case but I'm am all ears in case this is a nicer approach.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I found this stale issue that touches upon this same topic. #671
Currently the
losses.FocalLoss
interface doesn't allow to pass probabilities (unlike other Losses that have both a probs and logits implementation) and expects logits, which then are activated by a sigmoid in thelosses._functional.focal_loss_with_logits
function. Since sigmoid can only work in a binary case, the loss is calculated per class in binary fashion and then summed.Interestingly, there's also a softmax version in
losses._functional.softmax_focal_loss_with_logits
and it's more similar to how the FocalLoss works in segmentation_models for tensorflow/keras. In this case, the loss wouldn't need to be calculated per class in the wrapper.Is there any reason on why Focal Loss is calculated with this function and using sigmoid? Should the results be equivalent to softmax somehow? I would think softmax would be a more appropiate solution for the multiclass case but I'm am all ears in case this is a nicer approach.
Beta Was this translation helpful? Give feedback.
All reactions