Hi hs!



 hs99:

When I use NLLLoss as criterion for my CNN Model I get negative loss as shown :


NLLLoss requires its input to be log-probabilities.  To be valid
log-probabilities, these values must be non-positive.  You are passing
NLLLoss positive input values so it is returning negative (and
meaningless) values for the loss.
If you pass the output of your final Linear layer through a LogSoftmax
layer, the logits produced by the Linear layer (which can be positive)
will be converted to valid (and non-positive) log-probabilities.
Best.
K. Frank