Lesson-1 Issue-Valid: LabelList (0 items)

Hi Everyone,

I am a beginner in the area of Machine Learning/Deep Learning. I have completed lesson-1 of course-v3, and now I am trying to apply the same method (cat-dogs) to train a model that can predict the class of chemical compounds, either azulene or flavonol (these two classes of compounds have a significant difference in their chemical structure). I have a folder with 25 images of azulene derivatives and 25 images of flavanol derivatives. The images are labeled as Azulene_1, Azulene_2…Azuelene_25 and Flavanol_1, Flavanol_2…Flavanol_25. I was hoping that the trained model would predict whether the test set images are azulenes or flavonols. I am getting an issue when I run the following command:

data = ImageDataBunch.from_name_re(path_img, fnames, pat, ds_tfms=get_transforms(), size=224, bs=40)
data.normalize(imagenet_stats)

Issue:
/usr/local/lib/python3.6/dist-packages/fastai/data_block.py:541: UserWarning: You are labelling your items with CategoryList.
Your valid set contained the following unknown labels, the corresponding items have been discarded.
Flavonol_20, Azulene_11, Azulene_7, Azulene_19, Flavonol_12…
if getattr(ds, ‘warn’, False): warn(ds.warn)
ImageDataBunch;
Train: LabelList (40 items)
x: ImageList
Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224)
y: CategoryList
Azulene_15,Azulene_23,Azulene_9,Azulene_8,Flavonol_9
Path: /content/gdrive/MyDrive/Colab Notebooks/DL-Project/DL-1-Project/Train;

Valid: LabelList (0 items)
x: ImageList
y: CategoryList
Path: /content/gdrive/MyDrive/Colab Notebooks/DL-Project/DL-1-Project/Train;
Test: None

1.Why is my validation set empty? Why are my items being discarded? How do I fix the issue?
2. I was receiving an error indicating that the training dataloader is empty. I resolved that issue by changing bs=40 (assuming 40 is the total number of items in the training set). Any number below or above 40 is giving me an error. It would be of great help if anyone could explain to me the reason.

Thank you so much for your time!
Khushboo

@Ksingh
From what I can see from a very broad overlook, I think its an error in your pat Regex expression. You may have written some regex, but the model finds no such matching labels, so it basically discards everything.
Again, I would have to see your code to give you a better analysis.

Also, if you don’t mind me asking, is there a reason you are learning Deep learning through coursev3? Ofcourse, its totally your choice, but I feel I should share my own two cents with you, which sometimes goes a long way, especially when you have just begun a journey. I would personally recommend you start learning through course v4. Its not only more up to date, but the library itself is simpler, and better designed. By the way, welcome to the community!

Hi Palaash,

Thank you for your response. Per your suggestion, I tried modifying my pat re expression and it worked. I now have 10 items in my validation set. However, when I am printing (data.classes) it is showing three classes. I think it should be just two, azulene and flavanol. Any idea why that might be happening?

print(data.classes)
[‘Azulene’, ‘Flavanol’, ‘Flavonol’]

I was not aware of course-v4. I will start learning through course-v4. I appreciate you bringing this to my attention.

Hi Palaash,

I was able to resolve the issue with the classes that I mentioned in my previous post. I made an error naming the images. There was a space in the label str of two images belonging to flavanol category. Removing the space resolved the issue.
Thank you so much for your help!

Glad I could help
Cheers

1 Like