Hi Ritesh!



 ritesh313:




 KFrank:

As an aside, you don’t need the softmax() before the “maximum
index” (argmax()) to get the label prediction. softmax() doesn’t
change the order of its arguments, so you can leave it out.


I am doing that to get the index of the maximum value. Maybe I didn’t understand what you said?


Let’s call the output of your model logits.  What I mean is:
torch.argmax (torch.nn.functional.softmax (logits)) == torch.argmax (logits)

That is, even though the values returned by softmax() are different
than its inputs, the order of the returned values is the same as the
order of the inputs.  So leaving out softmax() won’t change the
result fo argmax().  (I’m just noting that while using softmax() is
valid, it’s not necessary.)
Best.
K. Frank