Classification problem in pytorch with loss function CrossEntropyLoss returns negative output in prediction
The numbers to which you are referring are probably the logits of the NN. The logits have to be transformed using a activation function which could be :


Softmax ( which you shown ) for classification tasks.
Linear activation function for regression tasks.


Softmax activation function :

The mathematical notion is as follows :

$\Large S( y_i ) = \frac{ e^{y_i}}{ \sum e^{y_i} }$

It converts the logits to class probabilities which sum upto 1. It is widely used in multiclass classification problems.

CNNs for classification need to produce class probabilities which are produced by a softmax activation function at the output layer.