111394:

I used the accuracy measurement method that I told you, but it always comes out as 1.
But the val accuracy is low.


using the data you provided in the initial post, the accuracy behaves as expected:
In  [1]: import torch
In  [2]: a = torch.tensor([[-21.6479, -24.8251, 46.5167],[-7.8592, -16.6111, 24.4777]])
In  [3]: a
Out [3]: tensor([[-21.6479, -24.8251,  46.5167],
                 [ -7.8592, -16.6111,  24.4777]])

In  [4]: b = torch.tensor([2, 2])
In  [5]: categorical_accuracy_with_logits(a,b)
Out [5]: tensor(1.)

In  [6]: b = torch.tensor([2, 1])
In  [7]: categorical_accuracy_with_logits(a,b)
Out [7]: tensor(0.5000)

In  [8]: b = torch.tensor([0, 0])
In  [9]: categorical_accuracy_with_logits(a,b)
Out [9]: tensor(0.)

Maybe there is overfitting happening on the trainset (you showed 1408 epochs maybe it’s too much), have you considered using EarlyStopping? (to stop the train if some metric is not improving for N amount of epoch, e.g. loss not decreasing anymore, or accuracy not increasing)
Roy