Skip to content

Commit

Permalink
Remove redundant code, Solve the data type inconsistency bug (#805)
Browse files Browse the repository at this point in the history
  • Loading branch information
wen-flow authored Jan 27, 2021
1 parent 840b9fd commit d7bfdfa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions paddleseg/models/losses/bootstrapped_cross_entropy.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ def __init__(self, min_K, loss_th, weight=None, ignore_index=255):
self.ignore_index = ignore_index
self.K = min_K
self.threshold = loss_th
if weight is not None:
weight = paddle.to_tensor(weight, dtype='float32')
self.weight = weight
self.ignore_index = ignore_index


def forward(self, logit, label):

n, c, h, w = logit.shape
Expand All @@ -55,7 +56,6 @@ def forward(self, logit, label):
y = paddle.transpose(y, (0, 2, 3, 1))
x = paddle.reshape(x, shape=(-1, c))
y = paddle.reshape(y, shape=(-1, ))

loss = F.cross_entropy(
x,
y,
Expand Down

0 comments on commit d7bfdfa

Please sign in to comment.