Error iterating DataLoader

I am having trouble with the dataloader.

normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])

dataset = datasets.ImageFolder(root='images', transform=transforms.Compose([normalize]))
test_loader =, batch_size=4, shuffle=True)
for i, (input, target) in enumerate(test_loader):

TypeError: zip argument #1 must support iteration

The “images” directory has single subdirectory with single image.

Maybe you could do something like this:

for i, itr in enumerate(test_loader):
     input, target = itr[0], itr[1]

It gives the same error. I think the problem is with test_loader not being iterable!

Oh silly mistake. I forgot to inclue ToTensor() transform.

This works;
dataset = datasets.ImageFolder(root='images', transform=transforms.Compose([transforms.ToTensor(), normalize]))