Skip to content

Commit

Permalink
Fix focal loss tests (#8920)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasHug authored Feb 20, 2025
1 parent b5c7443 commit f709766
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion torchvision/ops/focal_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def sigmoid_focal_loss(
"""
# Original implementation from https://github.com/facebookresearch/fvcore/blob/master/fvcore/nn/focal_loss.py

if not (0 <= alpha <= 1) or alpha != -1:
if not (0 <= alpha <= 1) and alpha != -1:
raise ValueError(f"Invalid alpha value: {alpha}. alpha must be in the range [0,1] or -1 for ignore.")

if not torch.jit.is_scripting() and not torch.jit.is_tracing():
Expand Down

0 comments on commit f709766

Please sign in to comment.