Issue with loading databunch

I’m trying to apply technique shown in lesson 1 to fashion mnist data set. I have imported data set in kaggle and trying to use it for simple neutral network. Here is my notebook
Here is my code:

class FashionMNIST(Dataset):
def __init__(self, path, transform=None):
    self.transform = transform
    fashion_df = pd.read_csv(path)
    self.labels = fashion_df.label.values
    self.images = fashion_df.iloc[:, 1:].values.astype('uint8').reshape(-1, 28, 28)

def __len__(self):
    return len(self.images)

def __getitem__(self, idx):
    label = self.labels[idx]
    img = Image.fromarray(self.images[idx])
    if self.transform:
        img = self.transform(img)

    return img, label
train_ds = FashionMNIST('../input/fashionmnist/fashion-mnist_train.csv')
test_ds = FashionMNIST('../input/fashionmnist/fashion-mnist_test.csv')
train_data_loader =, batch_size=16, shuffle=True)
test_data_loader =, batch_size=16, shuffle=False)
data = DataBunch.create(train_data_loader, test_data_loader)
learn = cnn_learner(data, models.resnet34, metrics=[accuracy])

Unfortunately, when I run my code I got following stacktrace:

/opt/conda/lib/python3.6/site-packages/fastai/ in DataLoader___getattr__(dl, k)
     18 = intercept_args
---> 20 def DataLoader___getattr__(dl, k:str)->Any: return getattr(dl.dataset, k)
     21 DataLoader.__getattr__ = DataLoader___getattr__
AttributeError: 'FashionMNIST' object has no attribute 'c'

Could anyone explain what is missing and why? I’ve opened source code and pytorch source code. In cnn_learner function I found following:

model = create_cnn_model(base_arch, data.c, cut, pretrained, lin_ftrs, ps=ps,     custom_head=custom_head, bn_final=bn_final, concat_pool=concat_pool)

If I understand this code correctly it is expected that DataBunch has property c. Also in data banch sources I found following:

def DataLoader___getattr__(dl, k:str)->Any: return getattr(dl.dataset, k)
DataLoader.__getattr__ = DataLoader___getattr__

If I’m not mistaken then it means we expect dataset to have property c.
Next step is pytorch dataset class that doesn’t have any property c. Could someone please explain what am I doing wrong? What is the issue with my code?

Thanks a lot in advance,

c is the amount of classes, you usually don’t have to worry about it but as you are extending from Dataset, seems you do. Extending from ImageList or something more fastaish would make these things simpler.