Git Product home page Git Product logo

continuum's Introduction

Continuum: Simple Management of Complex Continual Learning Scenarios

PyPI version Build Status Codacy Badge DOI Documentation Status coverage

Doc Paper Youtube

A library for PyTorch's loading of datasets in the field of Continual Learning

Aka Continual Learning, Lifelong-Learning, Incremental Learning, etc.

Read the documentation.
Test Continuum on Colab !

Example:

Install from and PyPi:

pip3 install continuum

And run!

from torch.utils.data import DataLoader

from continuum import ClassIncremental
from continuum.datasets import MNIST
from continuum.tasks import split_train_val

dataset = MNIST("my/data/path", download=True, train=True)
scenario = ClassIncremental(
    dataset,
    increment=1,
    initial_increment=5
)

print(f"Number of classes: {scenario.nb_classes}.")
print(f"Number of tasks: {scenario.nb_tasks}.")

for task_id, train_taskset in enumerate(scenario):
    train_taskset, val_taskset = split_train_val(train_taskset, val_split=0.1)
    train_loader = DataLoader(train_taskset, batch_size=32, shuffle=True)
    val_loader = DataLoader(val_taskset, batch_size=32, shuffle=True)

    for x, y, t in train_loader:
        # Do your cool stuff here

Supported Types of Scenarios

Name Acronym  Supported Scenario
New Instances  NI Instances Incremental
New Classes  NC Classes Incremental
New Instances & Classes  NIC Data Incremental

Supported Datasets:

Most dataset from torchvision.dasasets are supported, for the complete list, look at the documentation page on datasets here.

Furthermore some "Meta"-datasets are can be create or used from numpy array or any torchvision.datasets or from a folder for datasets having a tree-like structure or by combining several dataset and creating dataset fellowships!

Indexing

All our continual loader are iterable (i.e. you can for loop on them), and are also indexable.

Meaning that clloader[2] returns the third task (index starts at 0). Likewise, if you want to evaluate after each task, on all seen tasks do clloader_test[:n].

Example of Sample Images from a Continuum scenario

CIFAR10:

Task 0 Task 1 Task 2 Task 3 Task 4

MNIST Fellowship (MNIST + FashionMNIST + KMNIST):

Task 0 Task 1 Task 2

PermutedMNIST:

Task 0 Task 1 Task 2 Task 3 Task 4

RotatedMNIST:

Task 0 Task 1 Task 2 Task 3 Task 4

TransformIncremental + BackgroundSwap:

Task 0 Task 1 Task 2

Citation

If you find this library useful in your work, please consider citing it:

@misc{douillardlesort2021continuum,
  author={Douillard, Arthur and Lesort, Timothée},
  title={Continuum: Simple Management of Complex Continual Learning Scenarios},
  publisher={arXiv: 2102.06253},
  year={2021}
}

Maintainers

This project was started by a joint effort from Arthur Douillard & Timothée Lesort, and we are currently the two maintainers.

Feel free to contribute! If you want to propose new features, please create an issue.

Contributors: Lucas Caccia Lucas Cecchi Pau Rodriguez, Yury Antonov, psychicmario, fcld94, Ashok Arjun, Md Rifat Arefin, DanieleMugnai, Xiaohan Zou, Umberto Cappellazzo.

On PyPi

Our project is available on PyPi!

pip3 install continuum

Note that previously another project, a CI tool, was using that name. It is now there continuum_ci.

continuum's People

Contributors

arthurdouillard avatar ashok-arjun avatar jothamwong avatar lucasc-99 avatar pclucas14 avatar prlz77 avatar rarefin avatar ray-ruisun avatar renovamen avatar samuelmathieu-code avatar thomas-bouvier avatar tlesort avatar trellixvulnteam avatar vgthengane avatar yantonov 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  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

continuum's Issues

CIFAR-10/100 experiment of Zenke et al. (2017)

Hi @arthurdouillard,
Could you please tell me that your data loader API supports the CIFAR-10/100 experiment? This is an experiment I found in a paper called "continual learning with hyper-networks". BTW, I found there is a module named Fellowship which provides such a combination capability but I am not sure. May I ask you verify it?

MultiNLI scenario triggers torchvision. ValueError: pic should be 2/3 dimensional. Got 1 dimensions.

Hi, I tried to investigate how continual learning can be implemented in my NLP classification project. When I tried to see the MultiNLI first and tried to figure out what inside the train_loader using for loop, but an error occured:

dataset = MultiNLI('./data')
scenario = InstanceIncremental(dataset)
for task_id, train_taskset in enumerate(scenario):
    print(task_id, dir(train_taskset))
    train_taskset, val_taskset = split_train_val(train_taskset, val_split=0.1)
    train_loader = DataLoader(train_taskset, batch_size=32, shuffle=True)
    val_loader = DataLoader(val_taskset, batch_size=32, shuffle=True)

   for x,y,t in train_loader:
      print(x, y, t)

image

For full code:
https://colab.research.google.com/drive/1R8rYCo-0wzoiIUTE64Pko-GtfwbGGQ9C#scrollTo=R2SHCM83-Omg

Natural Language Processing

  • Language Modeling (forgot the ref)
  • Natural Language Inference (PROGRESSIVE MEMORY BANKS FOR INCREMENTAL DOMAIN ADAPTATION)
  • Topic classification

Error with Core50

There is an error when download is set to False

Core50("/data/douillard/CORe50", download=False, train=True)

However, it works with

Core50("/data/douillard/CORe50", download=True, train=True)

Semantic Segmentation

Need to support:

  • Sequential of Michieli
  • Disjoint and Overlap of Cermelli

For at least the datasets VOC and ADE20k.

AttributeError: 'TaskSet' object has no attribute 'open_image'

I have tested your snippet (provided bellow) on two devices and I received this error:

from torch.utils.data import DataLoader

from continuum import ClassIncremental
from continuum.datasets import MNIST

clloader = ClassIncremental(
    MNIST("my/data/path", download=True),
    increment=1,
    initial_increment=5,
    train=True  # a different loader for test
)

print(f"Number of classes: {clloader.nb_classes}.")
print(f"Number of tasks: {clloader.nb_tasks}.")

for task_id, train_dataset in enumerate(clloader):
    train_dataset, val_dataset = split_train_val(train_dataset)
    train_loader = DataLoader(train_dataset)
    val_loader = DataLoader(val_dataset)

and the error is:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-6-c5312f5c2b3b> in <module>()
      1 for task_id, train_dataset in enumerate(clloader):
----> 2     train_dataset, val_dataset = split_train_val(train_dataset)
      3     train_loader = DataLoader(train_dataset)
      4     val_loader = DataLoader(val_dataset)

/usr/local/lib/python3.6/dist-packages/continuum/task_set.py in split_train_val(dataset, val_split)
    118 
    119     x, y = dataset.x, dataset.y
--> 120     train_dataset = TaskSet(x[train_indexes], y[train_indexes], dataset.trsf, dataset.open_image)
    121     val_dataset = TaskSet(x[val_indexes], y[val_indexes], dataset.trsf, dataset.open_image)
    122 

AttributeError: 'TaskSet' object has no attribute 'open_image'

May I ask you what is the problem?

Question Regarding Permuted MNIST

Hi,

May I ask you to provide me a snippet for loading data related to the permuted MNIST scenario? I assumed that the following one does the same. Is it right?

from continuum.datasets import MNIST
from continuum import InstanceIncremental
clloader = InstanceIncremental(MNIST(args.data, download=True),
                                nb_tasks=10,
                                train=True)

Speed test for transformed

Tests for transformed are currently quite slow because it applies transformations on the whole MNIST.

We can speed it up by either:

  • using a small subset of MNIST
  • using synthetic data

imageio isn't listed as a dependency

Hey there, thanks for your work!

imageio is used only at one place, in viz.py, and isn't listed as a dependency in the setup.py, therefore installing continuum via pip install continuum *works fine, but importing it raises an error

PyPi package name

Continuum is already taken on PyPi, by a CI project from 2014.

We need a name for the PyPi, alternative choices:

  • lifelong
  • deepcontinuum
  • torchcontinuum
    ...

EDIT: the owner of Continuum should give us soon the name.

you pip installation command installs a wrong version with an error!

Traceback (most recent call last):
File "main_cl_cifar10_100_scl_prototype_inference_end_to_end.py", line 23, in
from continuum.task_set import split_train_val
File "/home/mohammad/.local/lib/python3.6/site-packages/continuum/task_set.py", line 8, in
from continuum.viz import plot
ImportError: cannot import name 'plot'

Example code from README doesn't work (?)

When trying to run the example code, I get the following error:

from torch.utils.data import DataLoader

from continuum import ClassIncremental, split_train_val
from continuum.datasets import MNIST

clloader = ClassIncremental(
    MNIST("my/data/path", download=True),
    increment=1,
    initial_increment=5,
    train=True  # a different loader for test
)

print(f"Number of classes: {clloader.nb_classes}.")
print(f"Number of tasks: {clloader.nb_tasks}.")

for task_id, train_dataset in enumerate(clloader):
    train_dataset, val_dataset = split_train_val(train_dataset, val_split=0.1)
    train_loader = DataLoader(train_dataset)
    val_loader = DataLoader(val_dataset)
    for x, y in train_loader:
        print("Never gets here?")
        exit()
    # Do your cool stuff here
Number of classes: 10.
Number of tasks: 6.
Traceback (most recent call last):
  File "foo.py", line 20, in <module>
    for x, y in train_loader:
  File "/home/fabrice/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 345, in __next__
    data = self._next_data()
  File "/home/fabrice/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 385, in _next_data
    data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
  File "/home/fabrice/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/fabrice/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/fabrice/Source/SSCL/utils/continuum/continuum/task_set.py", line 96, in __getitem__
    t = self.t[index]
TypeError: 'Compose' object does not support indexing

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.