{"id":15035404,"url":"https://github.com/gmvandeven/continual-learning","last_synced_at":"2025-05-14T13:07:06.975Z","repository":{"id":38272603,"uuid":"150479999","full_name":"GMvandeVen/continual-learning","owner":"GMvandeVen","description":"PyTorch implementation of various methods for continual learning (XdG, EWC, SI, LwF, FROMP, DGR, BI-R, ER, A-GEM, iCaRL, Generative Classifier) in three different scenarios.","archived":false,"fork":false,"pushed_at":"2025-03-17T13:32:10.000Z","size":2821,"stargazers_count":1677,"open_issues_count":4,"forks_count":322,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-04-06T08:01:49.172Z","etag":null,"topics":["artificial-neural-networks","class-incremental-learning","continual-learning","deep-learning","distillation","domain-incremental-learning","elastic-weight-consolidation","generative-models","gradient-episodic-memory","icarl","incremental-learning","lifelong-learning","replay","replay-through-feedback","task-incremental-learning","variational-autoencoder"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GMvandeVen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-26T19:32:16.000Z","updated_at":"2025-04-02T09:00:18.000Z","dependencies_parsed_at":"2023-01-30T08:31:21.721Z","dependency_job_id":"b31659a2-aa6d-4626-b483-b948e712f291","html_url":"https://github.com/GMvandeVen/continual-learning","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GMvandeVen%2Fcontinual-learning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GMvandeVen%2Fcontinual-learning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GMvandeVen%2Fcontinual-learning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GMvandeVen%2Fcontinual-learning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GMvandeVen","download_url":"https://codeload.github.com/GMvandeVen/continual-learning/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248708432,"owners_count":21148993,"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":["artificial-neural-networks","class-incremental-learning","continual-learning","deep-learning","distillation","domain-incremental-learning","elastic-weight-consolidation","generative-models","gradient-episodic-memory","icarl","incremental-learning","lifelong-learning","replay","replay-through-feedback","task-incremental-learning","variational-autoencoder"],"created_at":"2024-09-24T20:28:34.917Z","updated_at":"2025-04-13T11:37:50.115Z","avatar_url":"https://github.com/GMvandeVen.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Continual Learning\n[![DOI](https://zenodo.org/badge/150479999.svg)](https://zenodo.org/badge/latestdoi/150479999)\n\nThis is a PyTorch implementation of the continual learning experiments with deep neural networks described in the\nfollowing article:\n* [Three types of incremental learning](https://www.nature.com/articles/s42256-022-00568-3) (2022, *Nature Machine Intelligence*)\n\nThis repository mainly supports experiments in the *academic continual learning setting*, whereby\na classification-based problem is split up into multiple, non-overlapping *contexts*\n(or *tasks*, as they are often called) that must be learned sequentially.\nSome support is also provided for running more flexible, \"task-free\" continual learning experiments\nwith gradual transitions between contexts.\n\n\n### Earlier version\nAn earlier version of the code in this repository can be found \n[in this branch](https://github.com/GMvandeVen/continual-learning/tree/preprints).\nThis version of the code was used for the continual learning experiments described\nin two preprints of the above article:\n- Three scenarios for continual learning (\u003chttps://arxiv.org/abs/1904.07734\u003e)\n- Generative replay with feedback connections as a general strategy for continual learning\n(\u003chttps://arxiv.org/abs/1809.10635\u003e)\n\n\n## Installation \u0026 requirements\nThe current version of the code has been tested with `Python 3.10.4` on a Fedora operating system\nwith the following versions of PyTorch and Torchvision:\n* `pytorch 1.11.0`\n* `torchvision 0.12.0`\n\nFurther Python-packages used are listed in `requirements.txt`.\nAssuming Python and pip are set up, these packages can be installed using:\n```bash\npip install -r requirements.txt\n```\n\nThe code in this repository itself does not need to be installed, but a number of scripts should be made executable:\n```bash\nchmod +x main*.py compare*.py all_results.sh\n```\n\n\n## NeurIPS tutorial \"Lifelong Learning Machines\"\nThis code repository is used for the\n[NeurIPS 2022 tutorial \"Lifelong Learning Machines\"](https://sites.google.com/view/neurips2022-llm-tutorial).\nFor details and instructions on how to re-run the experiments presented in this tutorial,\nsee the folder [NeurIPS-tutorial](NeurIPStutorial).\n\n\n## ICLR blog post \"On the computation of the Fisher Information in continual learning\"\nThis repository is also used for the\n[ICLR 2025 blog post \"On the computation of the Fisher Information in continual learning\"](https://arxiv.org/abs/2502.11756).\nFor details and instructions on how to re-run the experiments reported in this blog post,\nsee the folder [ICLR-blogpost](ICLRblogpost).\n\n\n## Demos\n##### Demo 1: Single continual learning experiment\n```bash\n./main.py --experiment=splitMNIST --scenario=task --si\n```\nThis runs a single continual learning experiment:\nthe method Synaptic Intelligence on the task-incremental learning scenario of Split MNIST\nusing the academic continual learning setting.\nInformation about the data, the network, the training progress and the produced outputs is printed to the screen.\nExpected run-time on a standard desktop computer is ~6 minutes, with a GPU it is expected to take ~3 minutes.\n\n##### Demo 2: Comparison of continual learning methods\n```bash\n./compare.py --experiment=splitMNIST --scenario=task\n```\nThis runs a series of continual learning experiments,\ncomparing the performance of various methods on the task-incremental learning scenario of Split MNIST.\nInformation about the different experiments, their progress and \nthe produced outputs (e.g., a summary pdf) are printed to the screen.\nExpected run-time on a standard desktop computer is ~100 minutes, with a GPU it is expected to take ~45 minutes.\n\n\n## Re-running the comparisons from the article\nThe script `all_results.sh` provides step-by-step instructions for re-running the experiments and re-creating the\ntables and figures reported in the article \"Three types of incremental learning\".\n\nAlthough it is possible to run this script as it is, it will take very long and it is probably sensible to parallellize\nthe experiments.\n\n\n## Running custom experiments\n#### Academic continual learning setting\nCustom individual experiments in the academic continual learning setting can be run with `main.py`.\nThe main options of this script are:\n- `--experiment`: how to construct the context set? (`splitMNIST`|`permMNIST`|`CIFAR10`|`CIFAR100`)\n- `--contexts`: how many contexts?\n- `--scenario`: according to which scenario? (`task`|`domain`|`class`)\n\nTo run specific methods, you can use the following:\n- Separate Networks: `./main.py --separate-networks`\n- Context-dependent-Gating (XdG): `./main.py --xdg`\n- Elastic Weight Consolidation (EWC): `./main.py --ewc` (read first: [ICLR-blogpost](ICLRblogpost/README.md))\n- Synaptic Intelligence (SI): `./main.py --si`\n- Learning without Forgetting (LwF): `./main.py --lwf`\n- Functional Regularization Of the Memorable Past (FROMP): `./main.py --fromp`\n- Deep Generative Replay (DGR): `./main.py --replay=generative`\n- Brain-Inspired Replay (BI-R): `./main.py --brain-inspired`\n- Experience Replay (ER): `./main.py --replay=buffer`\n- Averaged Gradient Episodic Memory (A-GEM): `./main.py --agem`\n- Generative Classifier: `./main.py --gen-classifier`\n- incremental Classifier and Representation Learning (iCaRL): `./main.py --icarl`\n\nTo run baseline models (see the article for details):\n- None (\"lower target\"): `./main.py`\n- Joint (\"upper target\"): `./main.py --joint`\n\nFor information on further options: `./main.py -h`.\nThe code supports combinations of several of the above methods.\nIt is also possible to create custom approaches by mixing components of different methods,\nalthough not all possible combinations have been tested.\n\n#### More flexible, \"task-free\" continual learning experiments\nCustom individual experiments in a more flexible, \"task-free\" continual learning setting can be run with \n`main_task_free.py`. The main options of this script are:\n- `--experiment`: how to construct the context set? (`splitMNIST`|`permMNIST`|`CIFAR10`|`CIFAR100`)\n- `--contexts`: how many contexts?\n- `--stream`: how to transition between contexts? (`fuzzy-boundaries`|`academic-setting`|`random`)\n- `--scenario`: according to which scenario? (`task`|`domain`|`class`)\n\nFor information on further options: `./main_task_free.py -h`. This script supports several of the above \ncontinual learning methods, but not (yet) all of them. Some methods have been slightly modified to \nmake them suitable for the absence of (known) context boundaries.\nIn particular, methods that normally perform a certain consolidation operation at context boundaries, instead perform\nthis consolidation operation every `X` iterations, whereby `X` is set with the option `--update-every`. \n\n## On-the-fly plots during training\nWith this code progress during training can be tracked with on-the-fly plots. This feature requires `visdom`, \nwhich can be installed as follows:\n```bash\npip install visdom\n```\nBefore running the experiments, the visdom server should be started from the command line:\n```bash\npython -m visdom.server\n```\nThe visdom server is now alive and can be accessed at `http://localhost:8097` in your browser (the plots will appear\nthere). The flag `--visdom` should then be added when calling `./main.py` or `./main_task_free.py` to run the experiments with on-the-fly plots.\n\nFor more information on `visdom` see \u003chttps://github.com/facebookresearch/visdom\u003e.\n\n\n### Citation\nIf you use this code in your research, please consider citing the main accompanying article:\n```\n@article{vandeven2022three,\n  title={Three types of incremental learning},\n  author={van de Ven, Gido M and Tuytelaars, Tinne and Tolias, Andreas S},\n  journal={Nature Machine Intelligence},\n  volume={4},\n  pages={1185--1197},\n  year={2022}\n}\n```\n\nThe BibTeX citations for the two preprints that were also produced using this code repository are given below.\nGenerally it is however preferred to cite the officially published version of the article,\nbut these preprints can be cited for aspects not featured in the published article.\n```\n@article{vandeven2019three,\n  title={Three scenarios for continual learning},\n  author={van de Ven, Gido M and Tolias, Andreas S},\n  journal={arXiv preprint arXiv:1904.07734},\n  year={2019}\n}\n\n@article{vandeven2018generative,\n  title={Generative replay with feedback connections as a general strategy for continual learning},\n  author={van de Ven, Gido M and Tolias, Andreas S},\n  journal={arXiv preprint arXiv:1809.10635},\n  year={2018}\n}\n```\n\n\n### Acknowledgments\nThe research project from which this code originated has been supported by an IBRO-ISN Research Fellowship,\nby the ERC-funded project *KeepOnLearning* (reference number 101021347),\nby the National Institutes of Health (NIH) under awards R01MH109556 (NIH/NIMH) and P30EY002520 (NIH/NEI),\nby the *Lifelong Learning Machines* (L2M) program of the Defence Advanced Research Projects Agency (DARPA)\nvia contract number HR0011-18-2-0025 and by the Intelligence Advanced Research Projects Activity (IARPA)\nvia Department of Interior/Interior Business Center (DoI/IBC) contract number D16PC00003.\nDisclaimer: views and conclusions contained herein are those of the authors and should not be interpreted\nas necessarily representing the official policies or endorsements, either expressed or implied,\nof NIH, DARPA, IARPA, DoI/IBC, or the U.S. Government.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmvandeven%2Fcontinual-learning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgmvandeven%2Fcontinual-learning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmvandeven%2Fcontinual-learning/lists"}