π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
fix -inf issue in focal loss
edgarriba4992bf3091ba
diff --git a/torchgeometry/losses/focal.py b/torchgeometry/losses/focal.pyindex b21fd18df..bf55fe7c4 100644--- a/torchgeometry/losses/focal.py+++ b/torchgeometry/losses/focal.py@@ -81,9 +81,9 @@ 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.gamma- loss_tmp = 1. - torch.sum(focal, dim=1)+ loss_tmp = torch.sum(focal, dim=1)loss = -1if self.reduction == 'none':