Train dataloader missing items from the train dataset

possible bug: The train data loader, when iterated over, doesn’t yield all the items from the trainset; it only yields full-sized mini-batches, leaving the last, smaller-sized minibatch out.

I first observed this issue in my own script, then I tested the data loader created in lesson1-pets.ipynb in fastai’s dl1 course - it behaves similarly as well.

Here’s the code and the corresponding output (note the first line of the output showing the number of examples in the trainloader followed by the same from the trainset):

for dl, ds in zip([data.train_dl, data.valid_dl], [data.train_ds, data.valid_ds]):
  tot_ex = 0
  for x, y in dl:
    print(tot_ex, len(ds.y))

5888 5912
1478 1478