Skip to content

Commit 6cd88df

Browse files
authored
fix: support for cases without a weight function (#2973)
1 parent e9a5967 commit 6cd88df

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ppcls/loss/multilabelloss.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def _labelsmoothing(self, target, class_num):
3939
def _binary_crossentropy(self, input, target, class_num):
4040
if self.weight_ratio:
4141
target, label_ratio = target[:, 0, :], target[:, 1, :]
42+
else:
43+
target = target[:, 0, :]
4244
if self.epsilon is not None:
4345
target = self._labelsmoothing(target, class_num)
4446
cost = F.binary_cross_entropy_with_logits(
@@ -95,7 +97,7 @@ def forward(self, x, target):
9597
# Asymmetric Clipping and Basic CE calculation
9698
if self.clip and self.clip > 0:
9799
pt = (1 - pred_sigmoid + self.clip).clip(max=1) \
98-
* (1 - target) + pred_sigmoid * target
100+
* (1 - target) + pred_sigmoid * target
99101
else:
100102
pt = (1 - pred_sigmoid) * (1 - target) + pred_sigmoid * target
101103

0 commit comments

Comments
 (0)