|
1 |
| -# CLsurvey |
2 |
| -Codebase of the continual learning survey: |
3 |
| -"Continual learning: A comparative study on how to defy forgetting in classification tasks." arXiv preprint arXiv:1909.08383 (2019). |
4 |
| -Code coming soon! |
| 1 | +# A continual learning survey: Defying forgetting in classification tasks |
| 2 | +Source code for the [Continual Learning survey paper](https://arxiv.org/abs/1909.08383): |
| 3 | + |
| 4 | +``` |
| 5 | +@article{de2019continual, |
| 6 | + title={A continual learning survey: Defying forgetting in classification tasks}, |
| 7 | + author={De Lange, Matthias and Aljundi, Rahaf and Masana, Marc and Parisot, Sarah and Jia, Xu and Leonardis, Ale{\v{s}} and Slabaugh, Gregory and Tuytelaars, Tinne}, |
| 8 | + journal={arXiv preprint arXiv:1909.08383}, |
| 9 | + year={2019} |
| 10 | +} |
| 11 | +``` |
| 12 | + |
| 13 | +The code contains a generalizing framework for 11 SOTA methods and 4 baselines: |
| 14 | +- Methods: SI, EWC, MAS, mean/mode-IMM, LWF, EBLL, PackNet, HAT, GEM, iCaRL |
| 15 | +- Baselines |
| 16 | + - Joint: Learn from all task data at once with a single head (multi-task learning baseline). |
| 17 | + - Finetuning: standard SGD |
| 18 | + - Finetuning with Full Memory replay: Allocate memory dynamically to incoming tasks. |
| 19 | + - Finetuning with Partial Memory replay: Divide memory a priori over all tasks. |
| 20 | + |
| 21 | + |
| 22 | +This source code is released under a Attribution-NonCommercial 4.0 International |
| 23 | +license, find out more about it in the [LICENSE file](LICENSE). |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | +## Pipeline |
| 29 | +**Reproducability**: Results from the paper can be obtained from [src/main_'dataset'.sh](src/main_tinyimagenet.sh). |
| 30 | +Full pipeline example in [src/main_tinyimagenet.sh](src/main_tinyimagenet.sh) . |
| 31 | + |
| 32 | +**Pipeline**: Constructing a custom pipeline typically requires the following steps. |
| 33 | +1. Project Setup |
| 34 | + 1. For all requirements see [requirements.txt](requirements.txt). |
| 35 | + Main packages can be installed as in |
| 36 | + ``` |
| 37 | + conda create --name <ENV-NAME> python=3.7 |
| 38 | + conda activate <ENV-NAME> |
| 39 | + |
| 40 | + # Main packages |
| 41 | + conda install -c conda-forge matplotlib tqdm |
| 42 | + conda install pytorch torchvision cudatoolkit=10.2 -c pytorch |
| 43 | + |
| 44 | + # For GEM QP |
| 45 | + conda install -c omnia quadprog |
| 46 | + |
| 47 | + # For PackNet: torchnet |
| 48 | + pip install git+https://github.com/pytorch/tnt.git@master |
| 49 | + ``` |
| 50 | + 1. Set paths in '[config.init](src/config.init)' (or leave default) |
| 51 | + 1. '{tr,test}_results_root_path': where to save training/testing results. |
| 52 | + 1. 'models_root_path': where to store initial models (to ensure same initial model) |
| 53 | + 1. 'ds_root_path': root path of your datasets |
| 54 | + 1. Prepare dataset: see [src/data](src/data)/"dataset"_dataprep.py (e.g. [src/data/tinyimgnet_dataprep.py](src/data/tinyimgnet_dataprep.py)) |
| 55 | +1. **Train** any out of the 11 SOTA methods or 4 baselines |
| 56 | + 1. **Regularization-based/replay methods:** We run a *first task model dump*, for Synaptic Intelligence (SI) as it acquires importance weights during training. |
| 57 | + Other methods start from this same initial model. |
| 58 | + 1. **Baselines/parameter isolation methods**: Start training sequence from scratch |
| 59 | +1. **Evaluate** performance, sequence for testing on a task is saved in dictionary format under *test_results_root_path* defined in [config.init](src/config.init). |
| 60 | +1. **Plot** the evaluation results, using one of the configuration files in [utilities/plot_configs](src/utilities/plot_configs) |
| 61 | + |
| 62 | +## Implement Your Method |
| 63 | +1. Find class "YourMethod" in [methods/method.py](src/methods/method.py). Implement the framework phases (documented in code). |
| 64 | +1. Implement your task-based training script in [methods](src/methods): methods/"YourMethodDir". |
| 65 | +The class "YourMethod" will call this code for training/eval/processing of a single task. |
| 66 | + |
| 67 | + |
| 68 | +## Project structure |
| 69 | +- [src/data](src/data): datasets and automated preparation scripts for Tiny Imagenet and iNaturalist. |
| 70 | +- [src/framework](src/framework): the novel task incremental continual learning framework. |
| 71 | +**main.py** starts training pipeline, specify *--test* argument to perform evaluation with **eval.py**. |
| 72 | +- [src/methods](src/methods): all methods source code and **method.py** wrapper. |
| 73 | +- [src/models](src/models): **net.py** all model preprocessing. |
| 74 | +- [src/utilities](src/utilities): utils used across all modules and plotting. |
| 75 | +- Config: |
| 76 | + - [src/data](src/data)/{datasets/models}: default datasets and models directory (see [config.init](src/config.init)) |
| 77 | + - [src/results](src/results)/{train/test}: default training and testing results directory (see [config.init](src/config.init)) |
| 78 | + |
| 79 | + |
| 80 | +## Credits |
| 81 | +- Consider citing our work upon using this repo. |
| 82 | +- Thanks to Huawei for funding this project. |
| 83 | +- Thanks to the following repositories: |
| 84 | + - https://github.com/rahafaljundi/MAS-Memory-Aware-Synapses |
| 85 | + - https://github.com/facebookresearch/GradientEpisodicMemory |
| 86 | + - https://github.com/arunmallya/packnet |
| 87 | + - https://github.com/joansj/hat |
| 88 | +* If you want to join the Continual Learning community, checkout https://www.continualai.org |
| 89 | + |
| 90 | +## Support |
| 91 | +* If you have troubles, please open a Git issue. |
| 92 | +* Have you defined your method in the framework and want to share it with the community? Send a pull request! |
0 commit comments