mmasana / FACIL

Framework for Analysis of Class-Incremental Learning with 12 state-of-the-art methods and 3 baselines.
https://arxiv.org/pdf/2010.15277.pdf
MIT License
512 stars 98 forks source link

How to adapt EWC and LWF for dynamic number of classes? #44

Closed appledora closed 3 months ago

appledora commented 3 months ago

Hello, does FACIL support multihead classification for EWC and LWF ? To elaborate, I am trying to setup each dataset (with different umber of classes) as a task and perform continual learning. Do you have any suggestions on this?

Thanks

mmasana commented 3 months ago

Hi @appledora ,

Yes, it is supported. If each dataset is a different task, you can define them in src/datasets/dataset_config.py, and each will have their own head (check how to add the datasets in this README).

Most of the methods like EWC and LwF work with a concatenation of those heads, but you have access to each individually if needed. You can always modify if you want single- or multi-head in both the train_epoch and eval methods. Check the default behaviour from the parent class for the metric calculation here to get an idea of how to do it.

If you need the dataset or task setting to be different, you can just modify the main script to add the heads you need with net.add_head( #numclasses ), and all heads added to that ModuleList will be available for the network architecture.

Hope that helps :)

appledora commented 3 months ago

This makes sense. Thanks!