Skip to content

Commit

Permalink
Merge pull request selimsef#6 from vessemer/master
Browse files Browse the repository at this point in the history
BCEDiceJaccardLoss fixes
  • Loading branch information
albu authored Sep 1, 2018
2 parents 1b9c320 + 5a94c9c commit cc21866
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions albu/src/pytorch_utils/loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ def __init__(self, weights, weight=None, size_average=True):

def forward(self, input, target):
loss = 0
sigmoid_input = torch.sigmoid(input)
for k, v in self.weights.items():
if not v:
if not v:
continue
val = self.mapping[k](input, target)
val = self.mapping[k](input if k == 'bce' else sigmoid_input, target)
self.values[k] = val
if k != 'bce':
loss += self.weights[k] * (1 - val)
Expand Down

0 comments on commit cc21866

Please sign in to comment.