Why the min loss is not zero in neither of MultiLabelSoftMarginLoss and BCEWithLogitsLoss

Hi Seyeeet!

BCEWithLogitsLoss takes raw-score logits (that run from -inf to
inf) as its input, but takes probabilities (0.0 to 1.0) as its target.

Instead of using 0.0 and 1.0 for your input, use very large negative
and positive values. Then you will get a loss of (something close to)
0.0.

(In general, you shouldn’t use BCELoss, but if you apply it to your
example values, you will get 0.0 for the loss.)

BCEWithLogitsLoss and MultiLabelSoftMarginLoss are essentially
the same. See, for example:

Best.

K. Frank

2 Likes