Hi Gopal!



 gokriznastic:

Hey, I have a multilabel classification which is not binary, i.e. each class can have more than 2 states. (in my case- positive, negative, uncertain). Can I use BCEWithLogitsLoss for this and if not then what loss function do you suggest?


Yes, you can.  The target for BCEWithLogitsLoss can be a
probability (number between 0 and 1) – it is not required to be
a class label (e.g., a number that is either 0 or 1).
So understand your target to be the probability of the sample
being in the “positive” class.  Then “positive” --> P = 1.0,
“negative” --> P = 0.0, and “uncertain” --> P = 0.5.
(If you had your training data so annotated, you could, of course,
use finer gradations, such as “leaning negative” --> P = 0.25,
and “leaning positive” --> P = 0.75, or the like.)
(In the future, it would probably help for forum search and navigation
if you could start a new thread with its own topic title for questions
like this.)
Best.
K. Frank