Hi,
I am trying the nn.BCELossWithLogits now, and this is my code:
    logits = torch.randn(1, 2, 4, 4)
    label = torch.randint(0, 2, (1, 4, 4))

    criteria_ce = nn.CrossEntropyLoss()
    loss = criteria_ce(logits, label)
    print(loss)

    criteria_bce = nn.BCEWithLogitsLoss()
    lb_one_hot = logits.data.clone().zero_().scatter_(1, label.unsqueeze(1), 1)
    loss = criteria_bce(logits, lb_one_hot)
    print(loss)

In theory, these two loss should have same value, since they are both binary classification loss. Why the loss value is actually different, with one to be 2.01 and the other to be 0.77 ?