Hi Alex!



 alx:

What do you use instead of argmax?


The short answer is that you threshold your single logit output
against 0.0, rather than running a set of nClass outputs through
argmax().
Let me confirm what I think you are asking:
In addition to calculating your loss function (used for training), you
often also want to calculate the accuracy of your predictions.
For a multi-class classification problem, you typically pass a set
of nClass predicted logits (or predicted probabilities) though
argmax() to get the single predicted integer class label (that
you then compare with your kown class label).  I assume that
this is the “argmax” you are talking about.
For a binary problem, your last Linear layer will output a single
predicted logit for the sample being in class-“1” (as opposed to
being in class-“0”).  (Or, if you pass this logit through a sigmoid(),
you will get the predicted probability of the sample being in class-“1”.)
In this case you threshold the output to get a binary prediction:
logit > 0.0 == True means you predict that the sample is
in class-“1” (and logit > 0.0 == False means class-“0”).  (If
you are working with probabilities, then prob > 0.5 == True
means class-“1”.)  You then compare this prediction with the known
class-“0” / class-“1” binary label for the sample in question.
Good luck
K. Frank