Ch02 This DataLoader does not contain any batches

Running this code:

bears = bears.new(item_tfms=RandomResizedCrop(128, min_scale=0.3))
dls = bears.dataloaders(path)
dls.train.show_batch(max_n=4, nrows=1, unique=True)

Returns:
ValueError: This DataLoader does not contain any batches

I have run all code before, run dls.train.items and there are items in the dataloader but no batches.

1 Like

Hi, I had the same problem, it came out because I was only testing a few images, the batch size is by default bs = 64. If you change that value for a lower one, it will work.

dls = bears.dataloaders(path,bs=5)
dls.show_batch(nrows=1, ncols=3)

3 Likes

Thanks! I got the same problem yesterday. :grinning:

1 Like

i was doing the same mistake. lol . i had a training set of 42000 images but i loaded just 10 of them in the datablock…