Hi all
I tried to define a function to create Dataloader, but when I did so, the returned Dataloader can’t work by using enumerate. Any idea? or I am not supposed to do so? The code is as below:
def create_dataloaders(dirs, phase, transform, batchsize):
phase_dir = dirs + ‘/’ + phase
phase_transforms = transforms.Compose(transform)
phase_dataset = datasets.ImageFolder(phase_dir, transform=transform)
if phase == ‘train’:
dataloaders = torch.utils.data.DataLoader(phase_dataset, batch_size = batchsize, shuffle = True)
else:
dataloaders = torch.utils.data.DataLoader(phase_dataset, batch_size = batchsize, shuffle = False)
return dataloaders
for i, d in enumerate(create_dataloader):
print(i, d)
got error:
TypeError: ‘list’ object is not callable