Evaluation Code In CNN

Can you help me understand this highlighted line of code?:

def evaluation(dataloader):
    total , correct = 0 , 0
    for data in dataloader:
        inputs , labels = data
        outputs = net(inputs)
        ***_ , pred = torch.max(outputs.data ,1)***
        total +=  labels.size(0)
        correct += (pred == labels).sum().item()
    return 100 * correct / total

Hi @rakesh_singh,
If we check what torch.max actually does, we can see that it returns two tensors, one being the max values, and the second containing respective indices.
We just need indices for our further evaluation process, so we take a garbage variable _ in order to save the returned tensor which consists of max values.SmartSelect_20200524-063004_Google Go

1 Like