From 7e5a8727dec8f10bdbbadab913240af55614e905 Mon Sep 17 00:00:00 2001 From: milesial Date: Fri, 26 Oct 2018 18:53:05 +0200 Subject: [PATCH] Fixed math error in DiceLoss backward pass (#35) Former-commit-id: 649124b3bd26272bb8442843a546c4e895ec14ff --- dice_loss.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dice_loss.py b/dice_loss.py index fa2e987..631638f 100644 --- a/dice_loss.py +++ b/dice_loss.py @@ -20,7 +20,7 @@ class DiceCoeff(Function): grad_input = grad_target = None if self.needs_input_grad[0]: - grad_input = grad_output * 2 * (target * self.union + self.inter) \ + grad_input = grad_output * 2 * (target * self.union - self.inter) \ / self.union * self.union if self.needs_input_grad[1]: grad_target = None