What does '_,' do in PyTorch?

I am leaning the PyTorch tutorials, and I find that in the codes below, if I miss _, in front of ‘predicted’ in the second line, I’ll meet the error ‘only integer tensors of a single element can be converted to an index’, if I add _, in front of it, there’ll be no problems. Could anyone tell me what _, do and how _, do it? Thank you:)

outputs = net(images)
_, predicted = torch.max(outputs, 1)
print('Predicted: ', ' '.join('%5s' % classes[predicted[j]]
                              for j in range(4)))

‘net()’ is a CNN defined before, you can see it in Deep Learning with PyTorch: A 60 Minute Blitz > Training a Classifier


torch.max(input, dim, keepdim=False, out=None) -> (Tensor, LongTensor)

It just ignores the unneeded Tensor above.


Got it! Thank you very much!