Thank you for the explanation. Any idea how we can calculate this accuracy for segmentation task? I did the same thing but it returns an error.
correct = pred.eq(target.view(1, -1).expand_as(pred))

RuntimeError: The expanded size of the tensor (10) must match the existing size (768000) at non-singleton dimension 1.  Target sizes: [1, 10].  Tensor sizes: [1, 768000]