ky_Pa:

Does this line of code in question 2 mean that the index of pred_cls and labels is the same?


If the predicted indices and target indices are equal, your model predicted the right classes, otherwise the wrong ones.
Your code will give you the sum of correctly predicted classes, which is not the accuracy.
However, if you divide by the number of samples afterwards, it should work.
Also, don’t use the .data attribute as mentioned before.