Predicted labels stuck at 1 for test set where class 0 is 20% of data

unlike corssentropy which gets model score (-∞,+∞), BCELoss accept output of sigmoid layer as input.
if you want you can use

m = nn.Sigmoid()
loss = nn.BCELoss()
input = torch.randn(3, requires_grad=True)
target = torch.empty(3).random_(2)
output = loss(m(input[:,1]-input[:,0]), target)

with the same model or you can chage your model output shape to match the BCELoss.

1 Like