Official pytorch implementation of Rainbow Memory (CVPR 2021)

Overview

Rainbow Memory - Official PyTorch Implementation

Rainbow Memory: Continual Learning with a Memory of Diverse Samples
Jihwan Bang*, Heesu Kim*, YoungJoon Yoo, Jung-Woo Ha, Jonghyun Choi
CVPR 2021
Paper | Bibtex
(* indicates equal contribution)

NOTE: The code will be pushed to this repository soon.

Abstract

Continual learning is a realistic learning scenario for AI models. Prevalent scenario of continual learning, however, assumes disjoint sets of classes as tasks and is less realistic rather artificial. Instead, we focus on 'blurry' task boundary; where tasks shares classes and is more realistic and practical. To address such task, we argue the importance of diversity of samples in an episodic memory. To enhance the sample diversity in the memory, we propose a novel memory management strategy based on per-sample classification uncertainty and data augmentation, named Rainbow Memory (RM). With extensive empirical validations on MNIST, CIFAR10, CIFAR100, and ImageNet datasets, we show that the proposed method significantly improves the accuracy in blurry continual learning setups, outperforming state of the arts by large margins despite its simplicity.

Overview of the results of RM

The table is shown for last accuracy comparison in various datasets in Blurry10-Online. If you want to see more details, see the paper.

Methods MNIST CIFAR100 ImageNet
EWC 90.98±0.61 26.95±0.36 39.54
Rwalk 90.69±0.62 32.31±0.78 35.26
iCaRL 78.09±0.60 17.39±1.04 17.52
GDumb 88.51±0.52 27.19±0.65 21.52
BiC 77.75±1.27 13.01±0.24 37.20
RM w/o DA 92.65±0.33 34.09±1.41 37.96
RM 91.80±0.69 41.35±0.95 50.11

Updates

  • April 2nd, 2021: Initial upload only README
  • April 16th, 2021: Upload all the codes for experiments

Getting Started

Requirements

  • Python3
  • Pytorch (>1.0)
  • torchvision (>0.2)
  • numpy
  • pillow~=6.2.1
  • torch_optimizer
  • randaugment
  • easydict
  • pandas~=1.1.3

Datasets

All the datasets are saved in dataset directory by following formats as shown below.

[dataset name] 
    |_train
        |_[class1 name]
            |_00001.png
            |_00002.png 
            ...
        |_[class2 name]
            ... 
    |_test (val for ImageNet)
        |_[class1 name]
            |_00001.png
            |_00002.png
            ...
        |_[class2 name]
            ...

You can easily download the dataset following above format.

For ImageNet, you should download the public site.

Usage

To run the experiments in the paper, you just run experiment.sh.

bash experiment.sh 

For various experiments, you should know the role of each argument.

  • MODE: CIL methods. Our method is called rm. [joint, gdumb, icarl, rm, ewc, rwalk, bic] (joint calculates accuracy when training all the datasets at once.)
  • MEM_MANAGE: Memory management method. default uses the memory method which the paper originally used. [default, random, reservoir, uncertainty, prototype].
  • RND_SEED: Random Seed Number
  • DATASET: Dataset name [mnist, cifar10, cifar100, imagenet]
  • STREAM: The setting whether current task data can be seen iteratively or not. [online, offline]
  • EXP: Task setup [disjoint, blurry10, blurry30]
  • MEM_SIZE: Memory size cifar10: k={200, 500, 1000}, mnist: k=500, cifar100: k=2,000, imagenet: k=20,000
  • TRANS: Augmentation. Multiple choices [cutmix, cutout, randaug, autoaug]

Results

There are three types of logs during running experiments; logs, results, tensorboard. The log files are saved in logs directory, and the results which contains accuracy of each task are saved in results directory.

root_directory
    |_ logs 
        |_ [dataset]
            |_{mode}_{mem_manage}_{stream}_msz{k}_rnd{seed_num}_{trans}.log
            |_ ...
    |_ results
        |_ [dataset]
            |_{mode}_{mem_manage}_{stream}_msz{k}_rnd{seed_num}_{trans}.npy
            |_...

In addition, you can also use the tensorboard as following command.

tensorboard --logdir tensorboard

Citation

@inproceedings{jihwan2021rainbow,
  title={Rainbow Memory: Continual Learning with a Memory of Diverse Samples},
  author={Jihwan Bang, Heesu Kim, YoungJoon Yoo, Jung-Woo Ha, Jonghyun Choi},
  booktitle={CVPR},
  month={June},
  year={2021}
}

License

Copyright 2021-present NAVER Corp.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see .
Comments
  • Two questions about the data and metric in article.

    Two questions about the data and metric in article.

    I want to do some research based on your work, but I have two questions:

    1. In Table 6, why is the data in the uncertainty row and the CM+AA column different from the data in the RM row in Table 2. I think they are under the same setting.
    2. Calculating metric I5/I10 requires joint accuracy. For example, in the cifar100 in Table 1, the joint accuracy I reproduced is about 71, but in the RM row, the average value of I5 is only 20.18, 71-20=51, and A5 must be at least 51 accuracy.
    opened by GG-Bond-007 6
  • How to make blurry-M datasets?

    How to make blurry-M datasets?

    Hi! I am so interested in your work. And I want to do some research on other datasets with blurry setup. So I would like to ask you for help if you can share the code for making the burry dataset. I will appreciate it! Thank you!

    opened by GG-Bond-007 4
  • One quesion about accuracy in table 3:why online is better than offline?

    One quesion about accuracy in table 3:why online is better than offline?

    Hi! I am very interested in your work. But I have a question. Rainbow Memory get 66.25 in Blurry0(disjoint) online model in table3, bet get 61.91 in offline model . Generally, the online effect is worse than the offline effect, because the data of the current task can only be used once, and the data can only be reused in memory. However, there are not so many restrictions under the offline setting. Can you tell me why online is better than offline?

    opened by zhl98 2
  • One question about blurry setup

    One question about blurry setup

    Hi! I am very interested in your work. But I have a question. At the top of Figure 1 in the paper, category 3 does not appear in the previous task, but only appears in the current task. But in your experiment, the sample category of each task includes the category of the entire data set. I think this is a contradiction. So I want to ask in the blurry settings, does the previous task include the categories that are major categories of the following tasks? In your code, they are included, but Figure 1 does not seem to mean this. Is the picture wrong?

    opened by GG-Bond-007 2
  • Maybe some issues when calculating uncertainty

    Maybe some issues when calculating uncertainty

    I think there may be some issues when calculating the uncertainty in your code. https://github.com/clovaai/rainbow-memory/blob/d0442d49b0a3a2e7d9e49106bb92602a3cc2de3e/methods/finetune.py#L548 logit = self.model(x) logit = logit.detach().cpu() you use the output of FC layer to calculate the uncertainty.

    I think that a softmax is needed here.

    opened by SY-Xuan 2
  • There's a big difference between my results and yours

    There's a big difference between my results and yours

    hi,I ran "cifar10", but the results were significantly different from yours . Can you help me see what I did wrong? I set the parameters according to the file “experiment.sh”: --mode "rm" --mem_manage "default" --exp_name "blurry10" --dataset "cifar10" --stream_env "online" "--init_opt" --topk 1 --n_tasks 5 --n_cls_a_task 2 --n_init_cls 10 --rnd_seed 1 --model_name resnet18 --opt_name "sgd" --sched_name "cos" --lr 0.05 --batchsize 256 --n_worker 0 --n_epoch 16 --memory_size 500 --transform "cutmix autoaug" --uncert_metric "vr_randaug" --feature_size 2048 "--distilling" --joint_acc 0.0 And I recorded the output of the whole experiment : result.txt

    opened by zhangrunjiang 1
  • repeat experiment on online disjoint-CIL setup

    repeat experiment on online disjoint-CIL setup

    Hi, I have been trying to repeat the experiment on online disjoint-CIL setup (table 3 in the article). But even with data augmentation, the last accuracy I get using all the three seeds are around 40%. The change that I did to the experiment.sh is changing the EXP from blurry10 to disjoint. Am I miss some setting that cause this?

    opened by ray0nv3rt 1
  • There is a problem with the number of samples in the json file

    There is a problem with the number of samples in the json file

    On the CIFAR10 data set, there are a total of 5 tasks, and each task has two classes, so the number of samples in the training set for each task should be 10,000, but why is the number of samples in the json file 9750?

    opened by GG-Bond-007 1
  • Why considering blurry setting is better than the disjoint setting?

    Why considering blurry setting is better than the disjoint setting?

    Hi, the proposed rainbow-memory is impressive and inspiring. And I'm pretty curious about the setting. If a model is trained on disjoint setting, won't the blurry setting be eaiser for the model? In my understanding, in the disjoint setting, the distributions of different tasks are more different, causing more severe catastrophic forgetting and seemingly more difficult than the blurry setting in which the tasks share classes. I'd really appreciate it if I can get any response on this to help me better understand this problem!

    opened by b224618 1
  • .json files

    .json files

    Hi, I have a question about the .json files in the collections folder. Is it possible to share the code to create them? The notebook you are sharing doesn't seem to contain the code for that.

    Thank you very much

    opened by samin91 0
Owner
Clova AI Research
Open source repository of Clova AI Research, NAVER & LINE
Clova AI Research
Rainbow: Combining Improvements in Deep Reinforcement Learning

Rainbow Rainbow: Combining Improvements in Deep Reinforcement Learning [1]. Results and pretrained models can be found in the releases. DQN [2] Double

Kai Arulkumaran 1.4k Dec 29, 2022
BasicRL: easy and fundamental codes for deep reinforcement learning。It is an improvement on rainbow-is-all-you-need and OpenAI Spinning Up.

BasicRL: easy and fundamental codes for deep reinforcement learning BasicRL is an improvement on rainbow-is-all-you-need and OpenAI Spinning Up. It is

RayYoh 12 Apr 28, 2022
PyTorch Code of "Memory In Memory: A Predictive Neural Network for Learning Higher-Order Non-Stationarity from Spatiotemporal Dynamics"

Memory In Memory Networks It is based on the paper Memory In Memory: A Predictive Neural Network for Learning Higher-Order Non-Stationarity from Spati

Yang Li 12 May 30, 2022
Implementation of a memory efficient multi-head attention as proposed in the paper, "Self-attention Does Not Need O(n²) Memory"

Memory Efficient Attention Pytorch Implementation of a memory efficient multi-head attention as proposed in the paper, Self-attention Does Not Need O(

Phil Wang 180 Jan 5, 2023
Implementation of "Efficient Regional Memory Network for Video Object Segmentation" (Xie et al., CVPR 2021).

RMNet This repository contains the source code for the paper Efficient Regional Memory Network for Video Object Segmentation. Cite this work @inprocee

Haozhe Xie 76 Dec 14, 2022
Segcache: a memory-efficient and scalable in-memory key-value cache for small objects

Segcache: a memory-efficient and scalable in-memory key-value cache for small objects This repo contains the code of Segcache described in the followi

TheSys Group @ CMU CS 78 Jan 7, 2023
Episodic-memory - Ego4D Episodic Memory Benchmark

Ego4D Episodic Memory Benchmark EGO4D is the world's largest egocentric (first p

null 3 Feb 18, 2022
Official and maintained implementation of the paper "OSS-Net: Memory Efficient High Resolution Semantic Segmentation of 3D Medical Data" [BMVC 2021].

OSS-Net: Memory Efficient High Resolution Semantic Segmentation of 3D Medical Data Christoph Reich, Tim Prangemeier, Özdemir Cetin & Heinz Koeppl | Pr

Christoph Reich 23 Sep 21, 2022
This is the official PyTorch implementation for "Mesa: A Memory-saving Training Framework for Transformers".

Mesa: A Memory-saving Training Framework for Transformers This is the official PyTorch implementation for Mesa: A Memory-saving Training Framework for

Zhuang AI Group 105 Dec 6, 2022
git git《Transformer Meets Tracker: Exploiting Temporal Context for Robust Visual Tracking》(CVPR 2021) GitHub:git2] 《Masksembles for Uncertainty Estimation》(CVPR 2021) GitHub:git3]

Transformer Meets Tracker: Exploiting Temporal Context for Robust Visual Tracking Ning Wang, Wengang Zhou, Jie Wang, and Houqiang Li Accepted by CVPR

NingWang 236 Dec 22, 2022
Official pytorch implementation of paper "Inception Convolution with Efficient Dilation Search" (CVPR 2021 Oral).

IC-Conv This repository is an official implementation of the paper Inception Convolution with Efficient Dilation Search. Getting Started Download Imag

Jie Liu 111 Dec 31, 2022
Official PyTorch implementation of RobustNet (CVPR 2021 Oral)

RobustNet (CVPR 2021 Oral): Official Project Webpage Codes and pretrained models will be released soon. This repository provides the official PyTorch

Sungha Choi 173 Dec 21, 2022
Official Pytorch implementation of "Beyond Static Features for Temporally Consistent 3D Human Pose and Shape from a Video", CVPR 2021

TCMR: Beyond Static Features for Temporally Consistent 3D Human Pose and Shape from a Video Qualtitative result Paper teaser video Introduction This r

Hongsuk Choi 215 Jan 6, 2023
Official PyTorch Implementation of Embedding Transfer with Label Relaxation for Improved Metric Learning, CVPR 2021

Embedding Transfer with Label Relaxation for Improved Metric Learning Official PyTorch implementation of CVPR 2021 paper Embedding Transfer with Label

Sungyeon Kim 37 Dec 6, 2022
Official PyTorch implementation of the preprint paper "Stylized Neural Painting", accepted to CVPR 2021.

Official PyTorch implementation of the preprint paper "Stylized Neural Painting", accepted to CVPR 2021.

Zhengxia Zou 1.5k Dec 28, 2022
Official PyTorch Implementation of Convolutional Hough Matching Networks, CVPR 2021 (oral)

Convolutional Hough Matching Networks This is the implementation of the paper "Convolutional Hough Matching Network" by J. Min and M. Cho. Implemented

Juhong Min 70 Nov 22, 2022
Official PyTorch implementation of "VITON-HD: High-Resolution Virtual Try-On via Misalignment-Aware Normalization" (CVPR 2021)

VITON-HD — Official PyTorch Implementation VITON-HD: High-Resolution Virtual Try-On via Misalignment-Aware Normalization Seunghwan Choi*1, Sunghyun Pa

Seunghwan Choi 250 Jan 6, 2023
[CVPR 2021] Official PyTorch Implementation for "Iterative Filter Adaptive Network for Single Image Defocus Deblurring"

IFAN: Iterative Filter Adaptive Network for Single Image Defocus Deblurring Checkout for the demo (GUI/Google Colab)! The GUI version might occasional

Junyong Lee 173 Dec 30, 2022
Official PyTorch Code of GrooMeD-NMS: Grouped Mathematically Differentiable NMS for Monocular 3D Object Detection (CVPR 2021)

GrooMeD-NMS: Grouped Mathematically Differentiable NMS for Monocular 3D Object Detection GrooMeD-NMS: Grouped Mathematically Differentiable NMS for Mo

Abhinav Kumar 76 Jan 2, 2023