A PyTorch implementation of the continual learning experiments with deep neural networks

Overview

Brain-Inspired Replay

A PyTorch implementation of the continual learning experiments with deep neural networks described in the following paper:

This paper proposes a new, brain-inspired version of generative replay that can scale to continual learning problems with natural images as inputs. This is demonstrated with the Split CIFAR-100 protocol, both for task-incremental learning and for class-incremental learning.

Installation & requirements

The 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:

  • pytorch 1.1.0
  • torchvision 0.2.2

The versions that were used for other Python-packages are listed in requirements.txt.

To use the code, download the repository and change into it:

git clone https://github.com/GMvandeVen/brain-inspired-replay.git
cd brain-inspired-replay

(If downloading the zip-file, extract the files and change into the extracted folder.)

Assuming Python and pip are set up, the Python-packages used by this code can be installed using:

pip install -r requirements.txt

However, 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/).

Finally, the code in this repository itself does not need to be installed, but a number of scripts should be made executable:

chmod +x main_*.py compare_*.py create_figures.sh

Demos

Demo 1: Brain-inspired replay on split MNIST

./main_cl.py --experiment=splitMNIST --scenario=class --replay=generative --brain-inspired --pdf

This runs a single continual learning experiment: brain-inspired replay on the class-incremental learning scenario of split MNIST. Information about the data, the model, the training progress and the produced outputs (e.g., a pdf with results) is printed to the screen. Expected run-time on a standard laptop is ~12 minutes, with a GPU it should take ~4 minutes.

Demo 2: Comparison of continual learning methods

./compare_MNIST.py --scenario=class

This runs a series of continual learning experiments to compare the performance of various methods. Information about the different experiments, their progress and the produced outputs (e.g., a summary pdf) is printed to the screen. Expected run-time on a standard laptop is ~50 minutes, with a GPU it should take ~18 minutes.

These two demos can also be run with on-the-fly plots using the flag --visdom. For this visdom must be activated first, see instructions below.

Running comparisons from the paper

The script create_figures.sh provides step-by-step instructions for re-running the experiments and re-creating the figures reported in the paper.

Although it is possible to run this script as it is, it will take very long and it is probably sensible to parallellize the experiments.

Running custom experiments

Using main_cl.py, it is possible to run custom individual experiments. The main options for this script are:

  • --experiment: which task protocol? (splitMNIST|permMNIST|CIFAR100)
  • --scenario: according to which scenario? (task|domain|class)
  • --tasks: how many tasks?

To run specific methods, use the following:

  • Context-dependent-Gating (XdG): ./main_cl.py --xdg --xdg-prop=0.8
  • Elastic Weight Consolidation (EWC): ./main_cl.py --ewc --lambda=5000
  • Online EWC: ./main_cl.py --ewc --online --lambda=5000 --gamma=1
  • Synaptic Intelligenc (SI): ./main_cl.py --si --c=0.1
  • Learning without Forgetting (LwF): ./main_cl.py --replay=current --distill
  • Generative Replay (GR): ./main_cl.py --replay=generative
  • Brain-Inspired Replay (BI-R): ./main_cl.py --replay=generative --brain-inspired

For information on further options: ./main_cl.py -h.

PyTorch-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: https://github.com/GMvandeVen/continual-learning.

On-the-fly plots during training

With this code it is possible to track progress during training with on-the-fly plots. This feature requires visdom. Before running the experiments, the visdom server should be started from the command line:

python -m visdom.server

The visdom server is now alive and can be accessed at http://localhost:8097 in your browser (the plots will appear there). The flag --visdom should then be added when calling ./main_cl.py to run the experiments with on-the-fly plots.

For more information on visdom see https://github.com/facebookresearch/visdom.

Citation

Please consider citing our paper if you use this code in your research:

@article{vandeven2020brain,
  title={Brain-inspired replay for continual learning with artificial neural networks},
  author={van de Ven, Gido M and Siegelmann, Hava T and Tolias, Andreas S},
  journal={Nature Communications},
  volume={11},
  pages={4069},
  year={2020}
}

Acknowledgments

The research project from which this code originated has been supported by an IBRO-ISN Research Fellowship, by the Lifelong Learning Machines (L2M) program of the Defence Advanced Research Projects Agency (DARPA) via contract number HR0011-18-2-0025 and by the Intelligence Advanced Research Projects Activity (IARPA) via Department of Interior/Interior Business Center (DoI/IBC) contract number D16PC00003. Disclaimer: views and conclusions contained herein are those of the authors and should not be interpreted as necessarily representing the official policies or endorsements, either expressed or implied, of DARPA, IARPA, DoI/IBC, or the U.S. Government.

Owner
Working at the intersection of Machine Learning, Computational Neuroscience and Cognitive Science.
AI-generated-characters for Learning and Wellbeing

AI-generated-characters for Learning and Wellbeing Click here for the full project page. This repository contains the source code for the paper AI-gen

MIT Media Lab 214 Jan 01, 2023
Automatic packaging of the open-composite libs for OvGME

OvGME Packager for OpenXR ā€“ OpenComposite for DCS Note This repository is currently unsupported and needs to be migrated to the upstream OpenComposite

12 Nov 03, 2022
Generative Models as a Data Source for Multiview Representation Learning

GenRep Project Page | Paper Generative Models as a Data Source for Multiview Representation Learning Ali Jahanian, Xavier Puig, Yonglong Tian, Phillip

Ali 81 Dec 03, 2022
Realistic lighting in ursina!

Ursina Lighting Realistic lighting in ursina! If you want to have realistic lighting in ursina, import the UrsinaLighting.py in your project and use t

17 Jul 07, 2022
Repo for CReST: A Class-Rebalancing Self-Training Framework for Imbalanced Semi-Supervised Learning

CReST in Tensorflow 2 Code for the paper: "CReST: A Class-Rebalancing Self-Training Framework for Imbalanced Semi-Supervised Learning" by Chen Wei, Ki

Google Research 75 Nov 01, 2022
AOT (Associating Objects with Transformers) in PyTorch

An efficient modular implementation of Associating Objects with Transformers for Video Object Segmentation in PyTorch

162 Dec 14, 2022
Create Own QR code with Python

Create-Own-QR-code Create Own QR code with Python SO guys in here, you have to install pyqrcode 2. open CMD and type python -m pip install pyqrcode

JehanKandy 10 Jul 13, 2022
I3-master-layout - Simple master and stack layout script

Simple master and stack layout script | ------ | ----- | | | | | Ma

Tobias S 18 Dec 05, 2022
Python code for the paper How to scale hyperparameters for quickshift image segmentation

How to scale hyperparameters for quickshift image segmentation Python code for the paper How to scale hyperparameters for quickshift image segmentatio

0 Jan 25, 2022
Character Grounding and Re-Identification in Story of Videos and Text Descriptions

Character in Story Identification Network (CiSIN) This project hosts the code for our paper. Youngjae Yu, Jongseok Kim, Heeseung Yun, Jiwan Chung and

8 Dec 09, 2022
This is the PyTorch implementation of GANs Nā€™ Roses: Stable, Controllable, Diverse Image to Image Translation

Official PyTorch repo for GAN's N' Roses. Diverse im2im and vid2vid selfie to anime translation.

1.1k Jan 01, 2023
AdaMML: Adaptive Multi-Modal Learning for Efficient Video Recognition

AdaMML: Adaptive Multi-Modal Learning for Efficient Video Recognition [ArXiv] [Project Page] This repository is the official implementation of AdaMML:

International Business Machines 43 Dec 26, 2022
the official implementation of the paper "Isometric Multi-Shape Matching" (CVPR 2021)

Isometric Multi-Shape Matching (IsoMuSh) Paper-CVF | Paper-arXiv | Video | Code Citation If you find our work useful in your research, please consider

Maolin Gao 9 Jul 17, 2022
A setup script to generate ITK Python Wheels

ITK Python Package This project provides a setup.py script to build ITK Python binary packages and infrastructure to build ITK external module Python

Insight Software Consortium 59 Dec 14, 2022
3D-Transformer: Molecular Representation with Transformer in 3D Space

3D-Transformer: Molecular Representation with Transformer in 3D Space

55 Dec 19, 2022
Differentiable molecular simulation of proteins with a coarse-grained potential

Differentiable molecular simulation of proteins with a coarse-grained potential This repository contains the learned potential, simulation scripts and

UCL Bioinformatics Group 44 Dec 10, 2022
OpenAi's gym environment wrapper to vectorize them with Ray

Ray Vector Environment Wrapper You would like to use Ray to vectorize your environment but you don't want to use RLLib ? You came to the right place !

Pierre TASSEL 15 Nov 10, 2022
Repository for the paper : Meta-FDMixup: Cross-Domain Few-Shot Learning Guided byLabeled Target Data

1 Meta-FDMIxup Repository for the paper : Meta-FDMixup: Cross-Domain Few-Shot Learning Guided byLabeled Target Data. (ACM MM 2021) paper News! the rep

Fu Yuqian 44 Nov 18, 2022
InsTrim: Lightweight Instrumentation for Coverage-guided Fuzzing

InsTrim The paper: InsTrim: Lightweight Instrumentation for Coverage-guided Fuzzing Build Prerequisite llvm-8.0-dev clang-8.0 cmake = 3.2 Make git cl

75 Dec 23, 2022
An implementation for the loss function proposed in Decoupled Contrastive Loss paper.

Decoupled-Contrastive-Learning This repository is an implementation for the loss function proposed in Decoupled Contrastive Loss paper. Requirements P

Ramin Nakhli 71 Dec 04, 2022