Ismail_Elezi:

loss = criterion(outputs, labels)


Here labels must be the logarithm of a probability distribution, is it what you do ?
Because KLDivLoss will return sum(outputs * (log(outputs)-labels) so if your labels are (0 or 1)-vectors while outputs are probability smaller than one, you will necessary have negative values.