facebookresearch / fvcore

Collection of common code that's shared among different research projects in FAIR computer vision team.
Apache License 2.0
2k stars 226 forks source link

Why is the sigmoid function applied to logits before calling F.binary_cross_entropy_with_logits? #126

Closed kirill-menke closed 1 year ago

kirill-menke commented 1 year ago

In focal_loss.py you can find the following code snipped in sigmoid_focal_loss function:

https://github.com/facebookresearch/fvcore/blob/fd5043ff8b2e6790f5bd7c9632695c68986cc658/fvcore/nn/focal_loss.py#L35-L36

Why is the sigmoid function applied to the inputs before calculating the loss? Doesn't F.binary_cross_entropy_with_logits expect the raw logits?