If you want your network to give a single output then just try changing the loss to L1Loss. https://pytorch.org/docs/stable/nn.html#l1loss
But as I know if you are doing a classification problem then you need to follow something else. Just apply an activation after the last layer(containing 8 nodes). And then go by cross-entropy.
Basically, then your network will output 8 different values and each value tell the probability to occur for that class. So the node that contains the max value will be your class(predicted output).
I am still don’t get why you want to output a single value.
Please print your target/label and post it.