Different loopings through the dataloader

I have seen two types of for loops that go through the dataloader.

for batch_idx, (data,target) in enumerate(train_loader):
for data,target in train_loader:

Is there a difference between those two? If so, what is it?


In the first one you’ll get the current index of the iteration saved in batch_idx.
That’s what the enumerate op is for.
It’s often used e.g. if you would like to print some training stats every N batches.
Besides that, there is no difference.