ptrblck:

F.log_softmax expects logits which might have arbitrarily large and small numbers.


Ahh, got it.



 ptrblck:

As you can see, class3 has a probability of 0.1197 , so you’ll get a positive loss.


After applying F.nll_loss to this softmax output, I get a loss value of -0.1197 which is close to 0 but not exactly zero. Shouldn’t loss functions return exactly zero when prediction equals target like in this case?