π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
fix -inf issue in focal loss
edgarriba7d6a3262a94f
diff --git a/torchgeometry/losses/focal.py b/torchgeometry/losses/focal.pyindex b21fd18df..adf4a0e39 100644--- a/torchgeometry/losses/focal.py+++ b/torchgeometry/losses/focal.py@@ -81,7 +81,7 @@ class FocalLoss(nn.Module):device=input.device, dtype=input.dtype)# compute the actual focal loss- prob = input_soft * target_one_hot+ prob = input_soft * target_one_hot + self.epsfocal = -torch.log(prob) * self.alpha * (1. - prob) ** self.gammaloss_tmp = 1. - torch.sum(focal, dim=1)