Vision: ZeroDivisionError when running example code on own dataset

Running the example code on my own dataset results in a division by zero error.

data = ImageDataBunch.from_folder(’/Users/christiaanleysen/Desktop/dataset_2’,
ds_tfms=get_transforms(), tfms=imagenet_norm, size=224,num_workers=0)

learn = ConvLearner(data, models.resnet34, metrics=accuracy)
print(‘funetining layers’)
learn.fit_one_cycle(3, slice(1e-5,3e-4), pct_start=0.05)

Traceback (most recent call last):-----------------------------| 0.00% [0/2 00:00<00:00]
File “”, line 14, in
File “/anaconda3/lib/python3.6/site-packages/fastai/”, line 19, in fit_one_cycle, max_lr, wd=wd, callbacks=callbacks)
File “/anaconda3/lib/python3.6/site-packages/fastai/”, line 137, in fit
File “/anaconda3/lib/python3.6/site-packages/fastai/”, line 89, in fit
raise e
File “/anaconda3/lib/python3.6/site-packages/fastai/”, line 80, in fit
if cb_handler.on_batch_end(loss): break
File “/anaconda3/lib/python3.6/site-packages/fastai/”, line 238, in on_batch_end
stop = np.any(self(‘batch_end’, not self.state_dict[‘train’]))
File “/anaconda3/lib/python3.6/site-packages/fastai/”, line 187, in call
return [getattr(cb, f’on_{cb_name}’)(**self.state_dict, **kwargs) for cb in self.callbacks]
File “/anaconda3/lib/python3.6/site-packages/fastai/”, line 187, in
return [getattr(cb, f’on_{cb_name}’)(**self.state_dict, **kwargs) for cb in self.callbacks]
File “/anaconda3/lib/python3.6/site-packages/fastai/callbacks/”, line 43, in on_batch_end = self.lr_scheds[self.idx_s].step()
File “/anaconda3/lib/python3.6/site-packages/fastai/”, line 305, in step
return self.func(self.start, self.end, self.n/self.n_iter)
ZeroDivisionError: division by zero

1 Like

same here again… with fastai 1.0.11

All those cases look like problems of very small dataset. Can you share some more information like the number of elements in your training set, your batch size, the number of elements in train_dl?