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

FocalLoss without logits and as class #5762

Open
ori-kishony opened this issue Apr 6, 2022 · 1 comment
Open

FocalLoss without logits and as class #5762

ori-kishony opened this issue Apr 6, 2022 · 1 comment

Comments

@ori-kishony
Copy link

🚀 The feature

Making the focal loss api similar to BCE api. In which the difference between BCELoss and BCELossWithLogits is clear and is made as a class as well as a function.

Motivation, pitch

When using a model that explicitly uses the sigmoid activation at the end it is useful to be able to simply use focal loss without injecting the loss before this activation. The use of focal loss in the similar way to BCELoss as a class would also be more elegant and concise.

Alternatives

No response

Additional context

No response

@datumbox
Copy link
Contributor

datumbox commented Apr 6, 2022

@ori-kishony Thanks for the proposal. It's a good argument.

As you know, right now we offer a sigmoid_focal_loss method that does an explicit sigmoid call inside the method. One approach could be adding another focal_loss method that doesn't make this call. They should both share code to avoid duplication but not do the same logging calls.

An alternative approach is really mimic the BCE paradigm and rename methods but I'm not sure it's worth deprecating the previous method just to rename it.

Concerning on whether we should even do this, right now all TorchVision's models require the extra sigmoid call and wouldn't make use of the proposed feature. This doesn't mean that the feature isn't useful but we don't have an immediate use-case to cover. @fmassa do you have any thoughts on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants