Why do I get a different image at the same index?
I have the following code portion:
images = []
image_labels = []

for i, data in enumerate(train_loader,0):
        inputs, labels = data
        inputs, labels = inputs.to(device), labels.to(device)
        inputs, labels = inputs.float(), labels.float()
        images.append(inputs)
        image_labels.append(labels)

image = images[7]
image = image[0,...].permute([1,2,0])
image = image.numpy()
image = (image * 255).astype(np.uint8)
img = Image.fromarray(image,'RGB')
img.show()

As you can see, I'm trying to display the image at index 7. However, every time I run the code I get a different image displayed although using the same index, why is that?
The image displayed also is like degraded and has less quality than the original one.
Any thoughts on that?
Thanks.

My best bet is that you have your DataLoader's shuffle option set to True, in which case it would result in different images appearing at index 7. Every time you go through the iterator, the sequence of indices, used to access the underlying dataset, will be different.
