arthurdouillard / dytox

Dynamic Token Expansion with Continual Transformers, accepted at CVPR 2022

Home Page:https://arxiv.org/abs/2111.11326

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

task transform for previous task is None in RotMNIST

Kishaan opened this issue · comments

Hi,

I'm trying to integrate rotated MNIST dataset into the dytox repository and I'm using Rotations from continuum library to create the dataloader.

scenario = Rotations(
            cl_dataset=dataset,
            nb_tasks=args.number_of_tasks,
            base_transformations=transform.transforms,
            list_degrees=[0,22,45,67,90],
            shared_label_space=False
        )

I was able to run training for first task, however, I'm getting an error in the second task, for samples from first task, because from what I can see, the task transform is set to None for all other tasks other than the current task.

The error I'm getting is

  File "/volumes1/Home/anaconda3/envs/new-timm-env/lib/python3.8/site-packages/continuum/tasks/image_array_task_set.py", line 111, in _prepare_data
    x = self.get_task_trsf(t)(x)
TypeError: 'NoneType' object is not callable

And I think the reason is setting task transforms as None to other tasks than the current task in "continuum/scenarios/transformation_incremental.py" - Line 116

trsf = [  # Non-used tasks have a None trsf
            self.get_task_transformation(ti)
            if ti in task_index else None
            for ti in range(len(self))
        ]

I would like to know if there is any reason as to why it is set to None in this case. Could you also please tell me the most elegant way of having all task transforms throughout training so that this error can be avoided?

Hello @Kishaan,

I cannot reproduce your error. Here is my code:

from continuum import Rotations
from continuum.datasets import MNIST
from torchvision import transforms
from torch.utils.data import DataLoader
from matplotlib import pyplot as plt

dataset = MNIST("/data/douillard/")
scenario = Rotations(
    cl_dataset=dataset,
    nb_tasks=5,
    base_transformations=[transforms.ToTensor()],
    list_degrees=[0,22,45,67,90],
    shared_label_space=False
)

for taskset in scenario:
    loader = DataLoader(taskset)
    _ = next(iter(loader))
    taskset.plot()
    plt.pause(0.5)

# testing all rotations together
scenario[:len(scenario)].plot()

Can you provide code to reproduce your problem?

Btw, I've only tried this code with the latest version of Continuum, while DyTox was developped with an earlier version of Continuum. For a simple problem as RotMNIST which doesn't require multi-gpu/big resnet/mixed precision/fancy data aug, I think it would be easier to start from scratch.

Hi,

Maybe my version of continuum is a bit old, I'm using v1.2.1. I was able to fix it by changing the code in "continuum/scenarios/transformation_incremental.py" to always return transformations for every task instead of for current task samples alone. It happens only for buffered samples of task 1 when training task 2 (and similarly for all buffered samples of previous tasks when training the current task). In addition, as you mentioned, I'm not using any special augmentations or multi-gpu training. Thank you for the reply.