How do I calculate accuracy for multiclass problem?

There are 15 nodes in my output layer, one for each class.
I’m using CrossEntropyLoss to calculate the loss.
How do I calculate the accuracy here, the number of predicted labels that are equal to the target labels?
When I was using softmax and not CrossEntropyLoss I would just do target == torch.argmax(prediction) but since CrossEntropyLoss applies softmax itself, I’m not using softmax on final layer.

Would really appreciate if someone could help me out, thanks!

Hi jpj!

Please note that softmax() – which converts raw-score logits to
probabilities – does not change the order of the values. That is:

torch.argmax (prediction) == torch.argmax (torch.nn.functional.softmax (prediction))

Therefore you can continue to use:

target == torch.argmax (prediction)

unchanged.

Best.

K. Frank