Variable "_" incomprehensibility

I don’t understand the purpose of the simbol “_” on line 4 (which I can only find there).

count = 0
for x, y in torch.utils.data.DataLoader(dataset=validation_dataset, batch_size=1):
    z = model(x)
    _, yhat = torch.max(z, 1)
    if yhat != y:
        show_data((x, y))
        plt.show()
        print("yhat: ",yhat)
        count += 1
    if count >= 5:
        break  

thanks for your help.

It’s nothing special, just a variable name. However, it is conventional to use _ to mean “I don’t care about this value”

2 Likes

thanks Alice,I wasn’t sure.

1 Like