Skip to content

Commit

Permalink
Update loss.py
Browse files Browse the repository at this point in the history
  • Loading branch information
yxNONG authored and glenn-jocher committed Nov 25, 2020
1 parent 25239e1 commit 93120f2
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions utils/loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ def __init__(self, loss_fcn, gamma=1.5, alpha=0.25):
self.loss_fcn.reduction = 'none' # required to apply FL to each element

def forward(self, pred, true):
p_loss = self.loss_fcn(pred, true)
n_loss = self.loss_fcn(-pred, 1 - true)
loss = (true) * p_loss + (1 - true) * n_loss
loss = self.loss_fcn(pred, true)

pred_prob = torch.sigmoid(pred) # prob from logits
alpha_factor = true * self.alpha + (1 - true) * (1 - self.alpha)
Expand Down

0 comments on commit 93120f2

Please sign in to comment.