Skip to content

Commit

Permalink
[Fix] Problem of one hot when CELoss has weight (#2050)
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyutang authored May 10, 2022
1 parent 4fec7b3 commit 6fa1eb0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion paddleseg/models/losses/cross_entropy_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def _post_process_loss(self, logit, label, semantic_weights, loss):
loss = loss * semantic_weights

if self.weight is not None:
_one_hot = F.one_hot(label, logit.shape[-1])
_one_hot = F.one_hot(label * mask, logit.shape[-1])
coef = paddle.sum(_one_hot * self.weight, axis=-1)
else:
coef = paddle.ones_like(label)
Expand Down

0 comments on commit 6fa1eb0

Please sign in to comment.