I am trying to show the images along with respective labels being loaded in the data loader batch. Labels are: 0,1,2,3. However, the labels displayed on the top image are different from the labels that I simply print using the print command. Should not be both these labels same?
def imshow(inp, title=None):
"""Imshow for Tensor."""
inp = inp.numpy().transpose((1, 2, 0))
plt.imshow(inp)
if title is not None:
plt.title(title)
# Get a batch of training data
image, label = next(iter(train_loader))
print(label) # prinitng respective labels
# Make a grid from batch
out = torchvision.utils.make_grid(image)
imshow(out, title=[label[x] for x in label])
Below is the screenshot of printed labels and labels being displayed as titles on respective images.