Skip to content

Commit 63fa985

Browse files
authored
[Fix] Fix the error of BCE loss when batch size is 1. (open-mmlab#1629)
1 parent ef90522 commit 63fa985

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mmseg/models/losses/cross_entropy_loss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def binary_cross_entropy(pred,
124124
assert label[label != ignore_index].max() <= 1, \
125125
'For pred with shape [N, 1, H, W], its label must have at ' \
126126
'most 2 classes'
127-
pred = pred.squeeze()
127+
pred = pred.squeeze(1)
128128
if pred.dim() != label.dim():
129129
assert (pred.dim() == 2 and label.dim() == 1) or (
130130
pred.dim() == 4 and label.dim() == 3), \

0 commit comments

Comments
 (0)