Giter VIP home page Giter VIP logo

cn-dpm's Introduction

Continual Neural Dirichlet Process Mixture

Official PyTorch implementation of ICLR 2020 paper: A Neural Dirichlet Process Mixture Model for Task-Free Continual Learning.

Paper

CN-DPM

Experimental Results

Summarization of the main experiments

Method Split-MNIST
Acc. (%)
Split-MNIST (Gen.)
bits/dim
MNIST-SVHN
Acc.(%)
Split-CIFAR10
Acc.(%)
Split-CIFAR100
Acc.(%)
iid-offline 98.63 0.1806 96.69 93.17 73.80
iid-online 96.18 0.2156 95.24 62.79 20.46
Fine-tune 19.43 0.2817 83.35 18.08 2.43
Reservoir 85.69 0.2234 94.12 44.00 10.01
CN-DPM 93.23 0.2110 94.46 45.21 20.10

Training Graphs

Split-CIFAR10 (0.2 Epoch)

Split-CIFAR10 (0.2 Epoch)

Split-CIFAR100

Split-CIFAR100

System Requirements

  • Python >= 3.6.1
  • CUDA >= 9.0 supported GPU with at least 10GB memory

Installation

  1. Install PyTorch 1.0.1 and TorchVision 0.2.2 for your environment. Follow the instructions in HERE.

  2. Install other required packages.

$ pip install -r requirements.txt

Usage

$ python main.py --help
usage: main.py [-h] [--config CONFIG] [--episode EPISODE] [--log-dir LOG_DIR] [--override OVERRIDE]

optional arguments:
  -h, --help            show this help message and exit
  --config CONFIG, -c CONFIG
  --episode EPISODE, -e EPISODE
  --log-dir LOG_DIR, -l LOG_DIR
  --override OVERRIDE

Composing Continual Learning Episodes

We provide a quick and easy solution to compose continual learning scenarios. You can configure a scenario by writing a YAML file. Here is an example of Split-CIFAR10 where each stage is repeated for ten epochs:

- subsets: [['cifar10', 0], ['cifar10', 1]]
  epochs: 10
- subsets: [['cifar10', 2], ['cifar10', 3]]
  epochs: 10
- subsets: [['cifar10', 4], ['cifar10', 5]]
  epochs: 10
- subsets: [['cifar10', 6], ['cifar10', 7]]
  epochs: 10
- subsets: [['cifar10', 8], ['cifar10', 9]]
  epochs: 10

Basic rules:

  • Each scenario consists of a list of stages.
  • Each stage defines a list of subsets.
  • A subset is a two-element list [dataset_name, subset_name]. By default, each class is defined as a subset with the class number as its name.
  • Each stage may optionally define one of epochs, steps, and samples to set the length of the stage. Otherwise, the default length is set to 1 epoch.

The main logic is implemented in the DataScheduler in data.py.

Reproducing Experiments

Run the commands below to reproduce our experimental results. You can check the summaries on TensorBoard.

1. MNIST Generation

iid Offline

$ python main.py \
    --config configs/mnist_gen-iid_offline.yaml \
    --episode episodes/mnist-iid-100epochs.yaml \
    --log-dir log/mnist_gen-iid_offline

iid Online

$ python main.py \
    --config configs/mnist_gen-iid_online.yaml \
    --episode episodes/mnist-iid-online.yaml \
    --log-dir log/mnist_gen-iid_online

Finetune

$ python main.py \
    --config configs/mnist_gen-iid_online.yaml \
    --episode episodes/mnist-split-online.yaml \
    --log-dir log/mnist_gen-finetune

Reservoir

$ python main.py \
    --config configs/mnist_gen-reservoir.yaml \
    --episode episodes/mnist-split-online.yaml \
    --log-dir log/mnist_gen-reservoir

CN-DPM

$ python main.py \
    --config configs/mnist_gen-cndpm.yaml \
    --episode episodes/mnist-split-online.yaml \
    --log-dir log/mnist_gen-cndpm

2. MNIST Classification

iid Offline

$ python main.py \
    --config configs/mnist-iid_offline.yaml \
    --episode episodes/mnist-iid-100epochs.yaml \
    --log-dir log/mnist-iid_offline

iid Online

$ python main.py \
    --config configs/mnist-iid_online.yaml \
    --episode episodes/mnist-iid-online.yaml \
    --log-dir log/mnist-iid_online

Finetune

$ python main.py \
    --config configs/mnist-iid_online.yaml \
    --episode episodes/mnist-split-online.yaml \
    --log-dir log/mnist-finetune

Reservoir

$ python main.py \
    --config configs/mnist-reservoir.yaml \
    --episode episodes/mnist-split-online.yaml \
    --log-dir log/mnist-reservoir

CN-DPM

$ python main.py \
    --config configs/mnist-cndpm.yaml \
    --episode episodes/mnist-split-online.yaml \
    --log-dir log/mnist-cndpm

3. MNIST-SVHN Classification

iid Offline

$ python main.py \
    --config configs/mnist_svhn-iid_offline.yaml \
    --episode episodes/mnist_svhn-iid-10epochs.yaml \
    --log-dir log/mnist_svhn-iid_offline

iid Online

$ python main.py \
    --config configs/mnist_svhn-iid_online.yaml \
    --episode episodes/mnist_svhn-iid-online.yaml \
    --log-dir log/mnist_svhn-iid_online

Finetune

$ python main.py \
    --config configs/mnist_svhn-iid_online.yaml \
    --episode episodes/mnist_svhn-online.yaml \
    --log-dir log/mnist_svhn-finetune

Reservoir

$ python main.py \
    --config configs/mnist_svhn-reservoir.yaml \
    --episode episodes/mnist_svhn-online.yaml \
    --log-dir log/mnist_svhn-reservoir

CN-DPM

$ python main.py \
    --config configs/mnist_svhn-cndpm.yaml \
    --episode episodes/mnist_svhn-online.yaml \
    --log-dir log/mnist_svhn-cndpm

4. CIFAR10 Classification

iid Offline

$ python main.py \
    --config configs/cifar10-iid_offline.yaml \
    --episode episodes/cifar10-iid-100epochs.yaml \
    --log-dir log/cifar10-iid_offline

iid Online

$ python main.py \
    --config configs/cifar10-iid_online.yaml \
    --episode episodes/cifar10-iid-online.yaml \
    --log-dir log/cifar10-iid_online

Finetune

$ python main.py \
    --config configs/cifar10-iid_online.yaml \
    --episode episodes/cifar10-split-online.yaml \
    --log-dir log/cifar10-finetune

Reservoir

$ python main.py \
    --config configs/cifar10-reservoir.yaml \
    --episode episodes/cifar10-split-online.yaml \
    --log-dir log/cifar10-reservoir

CN-DPM

$ python main.py \
    --config configs/cifar10-cndpm.yaml \
    --episode episodes/cifar10-split-online.yaml \
    --log-dir log/cifar10-cndpm

CN-DPM (0.2 Epoch)

$ python main.py \
    --config configs/cifar10-cndpm.yaml \
    --episode episodes/cifar10-split-0.2epoch.yaml \
    --log-dir log/cifar10-cndpm-0.2epoch

CN-DPM (10 Epochs)

$ python main.py \
    --config configs/cifar10-cndpm.yaml \
    --episode episodes/cifar10-split-10epochs.yaml \
    --log-dir log/cifar10-cndpm-10epoch

5. CIFAR100 Classification

iid Offline

$ python main.py \
    --config configs/cifar100-iid_offline.yaml \
    --episode episodes/cifar100-iid-100epochs.yaml \
    --log-dir log/cifar100-iid_offline

iid Online

$ python main.py \
    --config configs/cifar100-iid_online.yaml \
    --episode episodes/cifar100-iid-online.yaml \
    --log-dir log/cifar100-iid_online

Finetune

$ python main.py \
    --config configs/cifar100-iid_online.yaml \
    --episode episodes/cifar100-split-online.yaml \
    --log-dir log/cifar100-finetune

Reservoir

$ python main.py \
    --config configs/reservoir-resnet_classifier-cifar100.yaml \
    --episode episodes/cifar100-split-online.yaml \
    --log-dir log/cifar100-reservoir

CN-DPM

$ python main.py \
    --config configs/cifar100-cndpm.yaml \
    --episode episodes/cifar100-split-online.yaml \
    --log-dir log/cifar100-cndpm

cn-dpm's People

Contributors

dependabot[bot] avatar soochan-lee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cn-dpm's Issues

Error when doing `pip install -r requirements.txt`

pip install -r requirements.txt gives the following error:

ERROR: Could not find a version that satisfies the requirement pytorch==1.0.1 (from -r requirements.txt (line 9)) (from versions: 0.1.2, 1.0.2)
ERROR: No matching distribution found for pytorch==1.0.1 (from -r requirements.txt (line 9))

It seems conda install pytorch==1.0.1 torchvision==0.2.2 -c pytorch works.

What are the key hyper-parameters to tune

Hi,

We are trying to apply CN-DPM on another dataset called CORE50 and the result is quite bad. Since CNDPM has so many hyper-parameters, except for log-alpha and classifier-chill, what hyper-parameters do you think are crucial to tune? Thank you so much and I look forward to hearing back from you.

Inference

Thank you very much for the code which is well written and easy to launch for training. I could train the generative model version however if I have troubles understanding how to run inference on external dataset from the saved model, could you provide some script to run testing?
For instance for reconstruction, do you always use the last expert, let say at the end of split-mnist if I want to retest on 0/1?

chilled_log_softmax

Firstly thank you so much for sharing the codebase. In the function nll(self, x, y, step=None), you calculate the chilled_log_softmax. I am wondering what's the meaning of it and why do you want to use it. Thank you in advance.

        # Classifier chilling
        chilled_log_softmax = F.log_softmax(
            log_softmax / self.config['classifier_chill'], dim=1)
        chilled_loss_pred = self.ce_loss(chilled_log_softmax, y)

        # Value with chill & gradient without chill
        loss_pred = loss_pred - loss_pred.detach() \
            + chilled_loss_pred.detach()

Saving checkpoint raises error

When I change the ckpt_step from 1000000000 to 10000 in cifar10-cndpm.yaml, it ave the following error:

Saving checkpoint... Traceback (most recent call last):
  File "main.py", line 92, in <module>
    main()
  File "main.py", line 88, in main
    train_model(config, model, data_scheduler, writer)
  File "./CN-DPM/train.py", line 76, in train_model
    pickle.dump(model, f)
AttributeError: Can't pickle local object 'CnnSharingVae.__init__.<locals>.<lambda>'

Low accuracy after data normalization

The original code works well on cifar100, however after I add normalization to cifar100 it gets very low accuracy. Is there any way to make it work on normalized dataset?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.