Jam:

However, my predictions are negative values (e.g. [-0.263, -0.308, -0.449, -0.279]). Before, when I was using BCELoss with Sigmoid, I received probabilities as output as I was expecting.


nn.BCEWithLogitsLoss expects logits (as given in the name), which are unbounded and can contain values in [-Inf, Inf] (of course they should contain valid values, since an Inf output would also yield an invalid loss value). If you want to convert these logits to probabilities for further processing, you could use torch.sigmoid on them. Note that you should not pass the probabilities (sigmoid outputs) to the criterion, but the logits.



 Jam:

I read the docs and it says that the output of BCELossWithLogits is the negative logarithm of the sigmoid (but the example stills shows a positive value).


The output of nn.BCEWithLogitsLoss is the binary cross-entropy loss and would take values in [0,+Inf] for the expected inputs.