From f7097666f0241548d354b338552e7b3c0d2956cd Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Thu, 20 Feb 2025 13:04:00 +0000 Subject: [PATCH] Fix focal loss tests (#8920) --- torchvision/ops/focal_loss.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchvision/ops/focal_loss.py b/torchvision/ops/focal_loss.py index abe861e8b03..5cd781eaab5 100644 --- a/torchvision/ops/focal_loss.py +++ b/torchvision/ops/focal_loss.py @@ -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():