I am aware the code is (How to predict only one test sample in pytorch model?):
pred = torch.max(output.data, 1)
as seen on the cifar10 beginner tutorial. But I’d like to understand why that’s correct.
I was reading the docs (https://pytorch.org/docs/stable/generated/torch.max.html) and it’s still not entirely clear to me. This is the sentence that doesn’t make sense to me:
Returns a namedtuple (values, indices) where values is the maximum value of each row of the input tensor in the given dimension dim.
I don’t understand what the max value of a row mean given a specific slice of a tensor. Rows only exist in 2D tensors (matrices), at least to me. Can you clarify?
Note that I do understand what the
dim is suppoe to do (see: https://towardsdatascience.com/understanding-dimensions-in-pytorch-6edf9972d3be)
ref/motivation, understand this clearly: Calculating accuracy of the current minibatch?