Oh, I forgot to say which is weird that you are not getting any error.
torch.max(tensor, dim) returns a tuple of values and corresponding indices. So change your code in this way:



 Py_Buddy:

_, true_y = labels.max(1)[1]
_, predicted_y = outputs.max(1)[1]


Finally, if you want to get loss values and aggregate them or anything that only related to its value as you said, you must use loss.item().



 Py_Buddy:

print('Loss: ', loss.item())