From 9251dfd6a5b94da52303d4b67eb16c8eb9ac48d6 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 1 Sep 2019 16:28:25 +0200 Subject: [PATCH] updates Signed-off-by: Glenn Jocher --- utils/utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/utils/utils.py b/utils/utils.py index 93653786..f7905c8b 100755 --- a/utils/utils.py +++ b/utils/utils.py @@ -301,8 +301,7 @@ class FocalLoss(nn.Module): def forward(self, input, target): loss = self.loss_fcn(input, target) - pt = torch.exp(-loss) - loss *= self.alpha * (1 - pt) ** self.gamma + loss *= self.alpha * (1.000001 - torch.exp(-loss)) ** self.gamma # non-zero power for gradient stability if self.reduction == 'mean': return loss.mean()