{"id":13738467,"url":"https://github.com/RaptorMai/online-continual-learning","last_synced_at":"2025-05-08T16:34:05.344Z","repository":{"id":40782739,"uuid":"334260720","full_name":"RaptorMai/online-continual-learning","owner":"RaptorMai","description":"A collection of online continual learning paper implementations and tricks for computer vision in PyTorch, including our ASER(AAAI-21), SCR(CVPR21-W) and an online continual learning survey (Neurocomputing). ","archived":false,"fork":false,"pushed_at":"2023-05-30T06:10:59.000Z","size":264,"stargazers_count":366,"open_issues_count":7,"forks_count":58,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-08-04T03:12:34.723Z","etag":null,"topics":["catastrophic-forgetting","class-incremental-learning","computer-vision","continual-learning","convolutional-neural-networks","deep-learning","incremental-continual-learning","incremental-learning","lifelong-learning","online-continual-learning"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RaptorMai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-01-29T20:54:21.000Z","updated_at":"2024-07-17T07:21:08.000Z","dependencies_parsed_at":"2024-01-07T21:14:45.680Z","dependency_job_id":null,"html_url":"https://github.com/RaptorMai/online-continual-learning","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaptorMai%2Fonline-continual-learning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaptorMai%2Fonline-continual-learning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaptorMai%2Fonline-continual-learning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaptorMai%2Fonline-continual-learning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RaptorMai","download_url":"https://codeload.github.com/RaptorMai/online-continual-learning/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224746759,"owners_count":17363108,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["catastrophic-forgetting","class-incremental-learning","computer-vision","continual-learning","convolutional-neural-networks","deep-learning","incremental-continual-learning","incremental-learning","lifelong-learning","online-continual-learning"],"created_at":"2024-08-03T03:02:23.265Z","updated_at":"2024-11-15T07:31:10.369Z","avatar_url":"https://github.com/RaptorMai.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Online Continual Learning\n![](aaai_aser.jpg)\n\nOfficial repository of \n* [Online Class-Incremental Continual Learning with Adversarial Shapley Value](https://arxiv.org/abs/2009.00093) (AAAI 2021)\n* [Supervised Contrastive Replay: Revisiting the Nearest Class Mean Classifier in Online Class-Incremental Continual Learning](https://openaccess.thecvf.com/content/CVPR2021W/CLVision/html/Mai_Supervised_Contrastive_Replay_Revisiting_the_Nearest_Class_Mean_Classifier_in_CVPRW_2021_paper.html) (CVPR2021 Workshop)\n* [Online Continual Learning in Image Classification: An Empirical Survey](https://arxiv.org/pdf/2101.10423.pdf) (Neurocomputing), [Official version](https://authors.elsevier.com/a/1e1YV3INukGu7J)\n\n\n## Requirements\n![](https://img.shields.io/badge/python-3.7-green.svg)\n\n![](https://img.shields.io/badge/torch-1.5.1-blue.svg)\n![](https://img.shields.io/badge/torchvision-0.6.1-blue.svg)\n![](https://img.shields.io/badge/PyYAML-5.3.1-blue.svg)\n![](https://img.shields.io/badge/scikit--learn-0.23.0-blue.svg)\n----\nCreate a virtual enviroment\n```sh\nvirtualenv online-cl\n```\nActivating a virtual environment\n```sh\nsource online-cl/bin/activate\n```\nInstalling packages\n```sh\npip install -r requirements.txt\n```\n\n## Datasets \n\n### Online Class Incremental\n- Split CIFAR10\n- Split CIFAR100\n- CORe50-NC\n- Split Mini-ImageNet\n\n### Online Domain Incremental\n- NonStationary-MiniImageNet (Noise, Occlusion, Blur)\n- CORe50-NI\n  \n### Data preparation\n- CIFAR10 \u0026 CIFAR100 will be downloaded during the first run\n- CORE50 download: `source fetch_data_setup.sh`\n- Mini-ImageNet: Download from https://www.kaggle.com/whitemoon/miniimagenet/download , and place it in datasets/mini_imagenet/\n- NonStationary-MiniImageNet will be generated on the fly\n\n\n## Algorithms \n\n* ASER: Adversarial Shapley Value Experience Replay(**AAAI, 2021**) [[Paper]](https://arxiv.org/abs/2009.00093)\n* EWC++: Efficient and online version of Elastic Weight Consolidation(EWC) (**ECCV, 2018**) [[Paper]](http://arxiv-export-lb.library.cornell.edu/abs/1801.10112)\n* iCaRL: Incremental Classifier and Representation Learning (**CVPR, 2017**) [[Paper]](https://arxiv.org/abs/1611.07725)\n* LwF: Learning without forgetting (**ECCV, 2016**) [[Paper]](https://link.springer.com/chapter/10.1007/978-3-319-46493-0_37)\n* AGEM: Averaged Gradient Episodic Memory (**ICLR, 2019**) [[Paper]](https://openreview.net/forum?id=Hkf2_sC5FX)\n* ER: Experience Replay (**ICML Workshop, 2019**) [[Paper]](https://arxiv.org/abs/1902.10486)\n* MIR: Maximally Interfered Retrieval (**NeurIPS, 2019**) [[Paper]](https://proceedings.neurips.cc/paper/2019/hash/15825aee15eb335cc13f9b559f166ee8-Abstract.html)\n* GSS: Gradient-Based Sample Selection (**NeurIPS, 2019**) [[Paper]](https://arxiv.org/pdf/1903.08671.pdf)\n* GDumb: Greedy Sampler and Dumb Learner (**ECCV, 2020**) [[Paper]](https://www.robots.ox.ac.uk/~tvg/publications/2020/gdumb.pdf)\n* CN-DPM: Continual Neural Dirichlet Process Mixture (**ICLR, 2020**) [[Paper]](https://openreview.net/forum?id=SJxSOJStPr)\n* SCR: Supervised Contrastive Replay (**CVPR Workshop, 2021**) [[Paper]](https://arxiv.org/abs/2103.13885) \n\n## Tricks\n- Label trick [[Paper]](https://arxiv.org/pdf/1803.10123.pdf)\n- Cross entropy with knowledge distillation [[Paper]](https://arxiv.org/abs/1807.09536)\n- Multiple iterations [[Paper]](https://proceedings.neurips.cc/paper/2019/hash/15825aee15eb335cc13f9b559f166ee8-Abstract.html)\n- Nearest Class Mean classifier [[Paper]](https://arxiv.org/abs/2004.00440)\n- Separated Softmax [[Paper]](https://arxiv.org/abs/2003.13947)\n- Review Trick [[Paper]](https://arxiv.org/abs/2007.05683)\n\n## Run commands\nDetailed descriptions of options can be found in [general_main.py](general_main.py)\n\n### Sample commands to run algorithms on Split-CIFAR100\n```shell\n#ER\npython general_main.py --data cifar100 --cl_type nc --agent ER --retrieve random --update random --mem_size 5000\n\n#MIR\npython general_main.py --data cifar100 --cl_type nc --agent ER --retrieve MIR --update random --mem_size 5000\n\n#GSS\npython general_main.py --data cifar100 --cl_type nc --agent ER --retrieve random --update GSS --eps_mem_batch 10 --gss_mem_strength 20 --mem_size 5000\n\n#LwF\npython general_main.py --data cifar100 --cl_type nc --agent LWF \n\n#iCaRL\npython general_main.py --data cifar100 --cl_type nc --agent ICARL --retrieve random --update random --mem_size 5000\n\n#EWC++\npython general_main.py --data cifar100 --cl_type nc --agent EWC --fisher_update_after 50 --alpha 0.9 --lambda_ 100\n\n#GDumb\npython general_main.py --data cifar100 --cl_type nc --agent GDUMB --mem_size 1000 --mem_epoch 30 --minlr 0.0005 --clip 10\n\n#AGEM\npython general_main.py --data cifar100 --cl_type nc --agent AGEM --retrieve random --update random --mem_size 5000\n\n#CN-DPM\npython general_main.py --data cifar100 --cl_type nc --agent CNDPM --stm_capacity 1000 --classifier_chill 0.01 --log_alpha -300\n\n#ASER\npython general_main.py --data cifar100 --cl_type nc --agent ER --update ASER --retrieve ASER --mem_size 5000 --aser_type asvm --n_smp_cls 1.5 --k 3 \n\n#SCR\npython general_main.py --data cifar100 --cl_type nc --agent SCR --retrieve random --update random --mem_size 5000 --head mlp --temp 0.07 --eps_mem_batch 100\n```\n\n### Sample command to add a trick to memory-based methods\n```shell\npython general_main.py --review_trick True --data cifar100 --cl_type nc --agent ER --retrieve MIR --update random --mem_size 5000 \n```\n\n### Sample commands to run hyper-parameters tuning \n```shell\npython main_tune.py --general config/general_1.yml --data config/data/cifar100/cifar100_nc.yml --default config/agent/mir/mir_1k.yml --tune config/agent/mir/mir_tune.yml\n```\nThere are four config files controling the experiment.\n\n- general config controls variables that are not changed during the experiment\n- data config controls variables related to the dataset\n- default method config controls variables for a specific method that are not changed during the experiment\n- method tuning config controls variables that are used for tuning during the experiment\n\n\n## Repo Structure \u0026 Description\n    ├──agents                       #Files for different algorithms\n        ├──base.py                      #Abstract class for algorithms\n        ├──agem.py                      #File for A-GEM\n        ├──cndpm.py                     #File for CN-DPM\n        ├──ewc_pp.py                    #File for EWC++\n        ├──exp_replay.py                #File for ER, MIR and GSS\n        ├──gdumb.py                     #File for GDumb\n        ├──iCaRL.py                     #File for iCaRL\n        ├──lwf.py                       #File for LwF\n        ├──scr.py                       #File for SCR\n    \n    ├──continuum                    #Files for create the data stream objects\n        ├──dataset_scripts              #Files for processing each specific dataset\n            ├──dataset_base.py              #Abstract class for dataset\n            ├──cifar10.py                   #File for CIFAR10\n            ├──cifar100,py                  #File for CIFAR100\n            ├──core50.py                    #File for CORe50\n            ├──mini_imagenet.py             #File for Mini_ImageNet\n            ├──openloris.py                 #File for OpenLORIS\n        ├──continuum.py             \n        ├──data_utils.py\n        ├──non_stationary.py\n    \n    ├──models                       #Files for backbone models\n        ├──ndpm                         #Files for models of CN-DPM \n            ├──...\n        ├──pretrained.py                #Files for pre-trained models\n        ├──resnet.py                    #Files for ResNet\n    \n    ├──utils                        #Files for utilities\n        ├──buffer                       #Files related to buffer\n            ├──aser_retrieve.py             #File for ASER retrieval\n            ├──aser_update.py               #File for ASER update\n            ├──aser_utils.py                #File for utilities for ASER\n            ├──buffer.py                    #Abstract class for buffer\n            ├──buffer_utils.py              #General utilities for all the buffer files\n            ├──gss_greedy_update.py         #File for GSS update\n            ├──mir_retrieve.py              #File for MIR retrieval\n            ├──random_retrieve.py           #File for random retrieval\n            ├──reservoir_update.py          #File for random update\n    \n        ├──global_vars.py               #Global variables for CN-DPM\n        ├──io.py                        #Code related to load and store csv or yarml\n        ├──kd_manager.py                #File for knowledge distillation\n        ├──name_match.py                #Match name strings to objects \n        ├──setup_elements.py            #Set up and initialize basic elements\n        ├──utils.py                     #File for general utilities\n    \n    ├──config                       #Config files for hyper-parameters tuning\n        ├──agent                        #Config files related to agents\n        ├──data                         #Config files related to dataset\n    \n        ├──general_*.yml                #General yml (fixed variables, not tuned)\n        ├──global.yml                   #paths to store results \n\n## Duplicate results\n\nThe hyperparameters used in the ASER and SCR papers can be found in the folder `config_CVPR` to duplicate the papers' results. \n\n## Citation \n\nIf you use this paper/code in your research, please consider citing us:\n\n**Supervised Contrastive Replay: Revisiting the Nearest Class Mean Classifier in Online Class-Incremental Continual Learning**\n\n[Accepted at CVPR2021 Workshop](https://arxiv.org/abs/2103.13885).\n```\n@inproceedings{mai2021supervised,\n  title={Supervised Contrastive Replay: Revisiting the Nearest Class Mean Classifier in Online Class-Incremental Continual Learning},\n  author={Mai, Zheda and Li, Ruiwen and Kim, Hyunwoo and Sanner, Scott},\n  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},\n  pages={3589--3599},\n  year={2021}\n}\n```\n\n**Online Continual Learning in Image Classification: An Empirical Survey**\n\nPublished in Neurocomputing, [official version](https://authors.elsevier.com/a/1e1YV3INukGu7J)\u003cbr/\u003e\nPreprint on arXiv [here](https://arxiv.org/pdf/2101.10423.pdf).\n\n```\n@article{MAI202228,\ntitle = {Online continual learning in image classification: An empirical survey},\njournal = {Neurocomputing},\nvolume = {469},\npages = {28-51},\nyear = {2022},\nissn = {0925-2312},\ndoi = {https://doi.org/10.1016/j.neucom.2021.10.021},\nurl = {https://www.sciencedirect.com/science/article/pii/S0925231221014995},\nauthor = {Zheda Mai and Ruiwen Li and Jihwan Jeong and David Quispe and Hyunwoo Kim and Scott Sanner}\n}\n```\n\n**Online Class-Incremental Continual Learning with Adversarial Shapley Value**\n\n[Accepted at AAAI2021](https://arxiv.org/abs/2009.00093)\n```\n@inproceedings{shim2021online,\n  title={Online Class-Incremental Continual Learning with Adversarial Shapley Value},\n  author={Shim, Dongsub and Mai, Zheda and Jeong, Jihwan and Sanner, Scott and Kim, Hyunwoo and Jang, Jongseong},\n  booktitle={Proceedings of the AAAI Conference on Artificial Intelligence},\n  volume={35},\n  number={11},\n  pages={9630--9638},\n  year={2021}\n}\n```\n\n## Contact \u0026 Contribution\n- [Zheda Mai](https://zheda-mai.github.io/) (Corresponding author)  \nzheda.mai@mail.utoronto.ca\n- [Ruiwen Li](https://www.linkedin.com/in/ruiwen-li-4a272b55/)\n- [Dongsub Shim](https://github.com/DongsubShim)\n\n\n## Acknowledgments\n- [MIR](https://github.com/optimass/Maximally_Interfered_Retrieval)\n- [GSS](https://github.com/rahafaljundi/Gradient-based-Sample-Selection)\n- [CN-DPM](https://github.com/soochan-lee/CN-DPM)\n- [GDumb](https://github.com/drimpossible/GDumb)\n- [AGEM](https://github.com/facebookresearch/agem)\n\n## Note\nThe PyTorch implementation of ASER in this repository is more efficient than the original TensorFlow implementation and has better performance.\nThe results of the ASER paper can be reproduced in the [original TensorFlow implementation repository](https://github.com/RaptorMai/ASER). \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRaptorMai%2Fonline-continual-learning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRaptorMai%2Fonline-continual-learning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRaptorMai%2Fonline-continual-learning/lists"}