Why next(iter(train_dataloader)) takes long execution time in PyTorch

36 Views Asked by At

I am trying to load a local dataset with images (around 225 images in total) using the following code:

# Set the batch size
BATCH_SIZE = 32 

# Create data loaders
train_dataloader, test_dataloader, class_names = data_setup.create_dataloaders(
  train_dir=train_dir,
  test_dir=test_dir,
  transform=manual_transforms, # use manually created transforms
  batch_size=BATCH_SIZE
)

# Get a batch of images
image_batch, label_batch = next(iter(train_dataloader)) # why it takes so much time? what can 
      I do about it?

My question concerns the last line of the code and the iteration in the train_dataloader which takes long execution time. Why is this the case? I have only 225 images.

0

There are 0 best solutions below