Sorry to revive this old thread, but what is the solution if the Datasets don’t have the same size?
Currently I’m using this approach:
for epoch in range(epochs):
   val_iter = itertools.cycle(validation_dataset_loader)
   for i_batch, data in enumerate(training_dataset_loader, 0):
      model.train()
      #training happens here
      
      model.eval()
      val_sample = next(val_iter)
      #evaluate performance on validation data

However I’m not sure if using the iterator here for the validation dataset is the best option, compared to the ‘enumerator’ approach, especially because the validation dataset is shuffled even when I explicitly set ‘shuffle=False’ when creating the validation DataLoader.
Thanks!