Problem with MNIST dataset

here is the problem am facing from almost 10 days but got no solution till now.
First I tried to create a model using MNIST_TINY dataset and I used ImageList for creating databunch. it worked fine and model was ready. i noticed that this dataset had three subfolders train,test and labels.csv.

now I tried it with MNIST dataset and when i try to create databunch using ImageList it shows a warning saying “training dataset is empty, valid dataset is empty” and
error-- “index 0 is out of bound for axis 0 and size 0:
exception-” Can’t infer the type of your targets.
It’s either because your data source is empty or because your labelling function raised an error."
i have also tried with ImageDataBunch but got same error.

i am using google colab. please help me with it.

Is there a reason why you are not using the DataBlock API?

Ohh i will try! By the way how do i know which api to use with which dataset?

The DataBlock API should be your go-to solution for almost anything.
It covers a lot of the most common use cases.
Here another very detailed tutorial, which also contains a MNIST example.

mnist = DataBlock(blocks=(ImageBlock(cls=PILImageBW), CategoryBlock), 

It works on MNIST_TINY but shows error in MNIST which has all classes from 0 to 9. That’s what i am saying.
And it is fastai v2. Is there any solution using fastai v1 or it is a bug?

1 Like

You are right. I did not notice.
For it to work you just have to fix the GrandparentSplitter, e.g. use splitter=GrandparentSplitter(train_name='training', valid_name='testing')

This is due to the fact that GrandparentSplitter's default train_name and valid_name are respectively train and valid. But if you look into MNIST’s path (using you would see that the folders are named differently (training and testing respectively).

MNIST path does not follow the

1 Like

Will try it!

when i do
data= mnist.dataloaders(path)
it shows an type error " ‘L’ object is not callable"

Are you using fastai2?
Can you please copy paste some code?
Can you please copy paste the stack trace?

i solved it using ImageDataBunch and finally it worked. thank you

@nitinmewar I am actually stuck on the same step … would you mind sharing the solution?

edit: was able to figure out!! :slight_smile: