Hi Shaun!



 shaun:

Hi,
I’m working on a binary classification problem with BCEWithLogitsLoss. My classes are just 0 and 1, such that my output is just single number. During testing, I would like to get the probabilities for each class. After running the test set through the model, I pass the outputed values through torch.sigmoid to get the probabilities. What I would like to know is, what that number signifies.
For example, if one of the output probability is 0.2. Does this mean that there is 0.2 output that this example belongs to class 0 or class 1?
Thanks.


In short, the output of sigmoid() is the (predicted) probability
of your sample  being in class “1”.  So, for your example,
P(class 1) = 0.2 (and P(class 2) = 0.8).
This can be found (a bit opaquely) in the BCEWithLogitsLoss 80
documentation, but you have to kind of parse through the
equations to get this information.
(As an aside, and as you are probably aware, the sigmoid
function is, in effect, built into BCEWithLogitsLoss.)
Good luck.
K. Frank