{"id":19858051,"url":"https://github.com/gmvandeven/brain-inspired-replay","last_synced_at":"2025-04-09T20:09:40.741Z","repository":{"id":37633440,"uuid":"284927011","full_name":"GMvandeVen/brain-inspired-replay","owner":"GMvandeVen","description":"A brain-inspired version of generative replay for continual learning with deep neural networks (e.g., class-incremental learning on CIFAR-100; PyTorch code).","archived":false,"fork":false,"pushed_at":"2023-07-06T21:28:10.000Z","size":25657,"stargazers_count":234,"open_issues_count":2,"forks_count":65,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-09T20:09:31.986Z","etag":null,"topics":["artificial-neural-networks","brain-inspired","continual-learning","deep-learning","distillation","elastic-weight-consolidation","generative-replay","incremental-learning","internal-replay","lifelong-learning","permuted-mnist","replay","replay-through-feedback","split-cifar100","split-mnist","synaptic-intelligence","variational-autoencoder"],"latest_commit_sha":null,"homepage":"","language":"Python","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}},"created_at":"2020-08-04T08:51:23.000Z","updated_at":"2025-02-25T02:50:01.000Z","dependencies_parsed_at":"2022-08-08T21:01:44.799Z","dependency_job_id":"31e750cf-3cd0-4c2d-b03d-af52fd768b4d","html_url":"https://github.com/GMvandeVen/brain-inspired-replay","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/GMvandeVen%2Fbrain-inspired-replay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GMvandeVen%2Fbrain-inspired-replay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GMvandeVen%2Fbrain-inspired-replay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GMvandeVen%2Fbrain-inspired-replay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GMvandeVen","download_url":"https://codeload.github.com/GMvandeVen/brain-inspired-replay/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103871,"owners_count":21048245,"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","brain-inspired","continual-learning","deep-learning","distillation","elastic-weight-consolidation","generative-replay","incremental-learning","internal-replay","lifelong-learning","permuted-mnist","replay","replay-through-feedback","split-cifar100","split-mnist","synaptic-intelligence","variational-autoencoder"],"created_at":"2024-11-12T14:21:00.487Z","updated_at":"2025-04-09T20:09:40.716Z","avatar_url":"https://github.com/GMvandeVen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Brain-Inspired Replay\nA PyTorch implementation of the continual learning experiments with deep neural networks described in the \nfollowing paper:\n* Brain-inspired replay for continual learning with artificial neural networks: https://www.nature.com/articles/s41467-020-17866-2\n\nThis paper proposes a new, brain-inspired version of generative replay that can scale to continual learning problems with natural images as inputs.\nThis is demonstrated with the Split CIFAR-100 protocol, both for task-incremental learning and for class-incremental learning.\n\n\n## Installation \u0026 requirements\nThe current version of the code has been tested with `Python 3.5.2` on several Linux operating systems with the following versions of PyTorch and Torchvision:\n* `pytorch 1.1.0`\n* `torchvision 0.2.2`\n\nThe versions that were used for other Python-packages are listed in `requirements.txt`.\n\nTo use the code, download the repository and change into it:\n```bash\ngit clone https://github.com/GMvandeVen/brain-inspired-replay.git\ncd brain-inspired-replay\n```\n(If downloading the zip-file, extract the files and change into the extracted folder.)\n \nAssuming  Python and pip are set up, the Python-packages used by this code can be installed using:\n```bash\npip install -r requirements.txt\n```\nHowever, you might want to install pytorch and torchvision in a slightly different way to ensure compatability with your version of CUDA (see https://pytorch.org/).\n\nFinally, the 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 create_figures.sh\n```\n\n\n## Demos\n\n#### Demo 1: Brain-inspired replay on split MNIST\n```bash\n./main_cl.py --experiment=splitMNIST --scenario=class --replay=generative --brain-inspired --pdf\n```\nThis runs a single continual learning experiment: brain-inspired replay on the class-incremental learning scenario of split MNIST.\nInformation about the data, the model, the training progress and the produced outputs (e.g., a pdf with results) is printed to the screen.\nExpected run-time on a standard laptop is ~12 minutes, with a GPU it should take ~4 minutes.\n\n#### Demo 2: Comparison of continual learning methods\n```bash\n./compare_MNIST.py --scenario=class\n```\nThis runs a series of continual learning experiments to compare the performance of various methods.\nInformation about the different experiments, their progress and the produced outputs (e.g., a summary pdf) is printed to the screen.\nExpected run-time on a standard laptop is ~50 minutes, with a GPU it should take ~18 minutes.\n\n\nThese two demos can also be run with on-the-fly plots using the flag `--visdom`.\nFor this visdom must be activated first, see instructions below.\n\n\n## Running comparisons from the paper\nThe script `create_figures.sh` provides step-by-step instructions for re-running the experiments and re-creating the \nfigures reported in the paper.\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\nUsing `main_cl.py`, it is possible to run custom individual experiments. The main options for this script are:\n- `--experiment`: which task protocol? (`splitMNIST`|`permMNIST`|`CIFAR100`)\n- `--scenario`: according to which scenario? (`task`|`domain`|`class`)\n- `--tasks`: how many tasks?\n\nTo run specific methods, use the following:\n- Context-dependent-Gating (XdG): `./main_cl.py --xdg --xdg-prop=0.8`\n- Elastic Weight Consolidation (EWC): `./main_cl.py --ewc --lambda=5000`\n- Online EWC:  `./main_cl.py --ewc --online --lambda=5000 --gamma=1`\n- Synaptic Intelligenc (SI): `./main_cl.py --si --c=0.1`\n- Learning without Forgetting (LwF): `./main_cl.py --replay=current --distill`\n- Generative Replay (GR): `./main_cl.py --replay=generative`\n- Brain-Inspired Replay (BI-R): `./main_cl.py --replay=generative --brain-inspired`\n\nFor information on further options: `./main_cl.py -h`.\n\nPyTorch-implementations for several methods relying on stored data (Experience Replay, iCaRL and A-GEM), as well as for additional metrics (FWT, BWT, forgetting, intransigence), can be found here: \u003chttps://github.com/GMvandeVen/continual-learning\u003e.\n\n\n## On-the-fly plots during training\nWith this code it is possible to track progress during training with on-the-fly plots. This feature requires `visdom`.\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_cl.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\nPlease consider citing our paper if you use this code in your research:\n```\n@article{vandeven2020brain,\n  title={Brain-inspired replay for continual learning with artificial neural networks},\n  author={van de Ven, Gido M and Siegelmann, Hava T and Tolias, Andreas S},\n  journal={Nature Communications},\n  volume={11},\n  pages={4069},\n  year={2020}\n}\n```\n\n### Acknowledgments\nThe research project from which this code originated has been supported by an IBRO-ISN Research Fellowship, by the \nLifelong Learning Machines (L2M) program of the Defence Advanced Research Projects Agency (DARPA) via contract number \nHR0011-18-2-0025 and by the Intelligence Advanced Research Projects Activity (IARPA) via Department of \nInterior/Interior Business Center (DoI/IBC) contract number D16PC00003. Disclaimer: views and conclusions \ncontained herein are those of the authors and should not be interpreted as necessarily representing the official\npolicies or endorsements, either expressed or implied, of DARPA, IARPA, DoI/IBC, or the U.S. Government.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmvandeven%2Fbrain-inspired-replay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgmvandeven%2Fbrain-inspired-replay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmvandeven%2Fbrain-inspired-replay/lists"}