Improve model for confused classes

Luckily I’ve got some interesting result using a kind of “Curriculum Learning”, feeding the model with high frequency classes first and low frequency later (using only frequency is very naive approach as @aamir7117 told me a lot of times :wink: ).
Focusing on samples where the model is not “confused” is way better and actually pretty simple to implement if you feed your own classes in the labelling step.

Train first with all data and measure the performance.
Pretend your model is good on classes A.B but confused on C,D,E. Then:

  1. Create classes list
allClasses = ['A','B','C','D','E']
  1. Create databunch for high frequency classes
dataAB = (ImageList.from_df(dataAB, path, cols=['Image'])
        .split_from_df('is_valid')
        .label_from_df('LBL', classes=allClasses) # THIS IS THE IMPORTANT STEP!
        .transform(tfms)
        .databunch(bs=64))
  1. Create the learner with dataAB
learn = cnn_learner(dataAB, models.resnet50)
  1. Train the model (should have higher accouracy)
  2. Create databunch for all classes (dataAll)
  3. Change the databunch in the learner
learn.data = dataAll
  1. Train with all classes

CURRICULUM LEARNING

image

2 Likes