Enumerate with zip for dataloader

I am training a network with two separate datasets. I use this line of code to iterate through both of them at the same time:

for epoch in range(M):
for i, (data1, data2) in enumerate(tqdm(zip(dataloader1, dataloader2), total = len(dataloader1))): Rest of code

dataloader 2 has twice as much images in total. And hence, this enumerate function will iterate through the shorter dataloader (dataloader1) and will go to the second epoch once the images in dataloader1 are done.

My question is, when I am in the second epoch, will dataloader2 start giving the remainder of the images it has? Or will it start from the beginning, giving the same set of images as in the first epoch.

In other words, in this way, am I wasting half of the images in dataloader2 and not using them at all?

If you don’t shuffle the datasets you would waste 50% of the second dataset. Otherwise the 50% of the samples will be randomly drawn.