Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

TypeError: 'str' object is not callable #107

Closed
lebrice opened this issue Mar 9, 2021 · 2 comments
Closed

TypeError: 'str' object is not callable #107

lebrice opened this issue Mar 9, 2021 · 2 comments

Comments

@lebrice
Copy link

lebrice commented Mar 9, 2021

""" Reproduce a bug in continuum package, specific to v1.0.9 """
from torch.utils.data import DataLoader

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


scenario = ClassIncremental(
    MNIST("data", download=True, train=True),
    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
        pass
$ python repro_bug.py 
Number of classes: 10.
Number of tasks: 6.
Traceback (most recent call last):
  File "repro_bug.py", line 23, in <module>
    for x, y, t in train_loader:
  File "/home/fabrice/miniconda3/envs/clcomp21/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 435, in __next__
    data = self._next_data()
  File "/home/fabrice/miniconda3/envs/clcomp21/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 475, in _next_data
    data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
  File "/home/fabrice/miniconda3/envs/clcomp21/lib/python3.8/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/clcomp21/lib/python3.8/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/miniconda3/envs/clcomp21/lib/python3.8/site-packages/continuum/tasks/task_set.py", line 175, in __getitem__
    y = self.target_trsf(y)
TypeError: 'str' object is not callable
@TLESORT
Copy link
Collaborator

TLESORT commented Mar 9, 2021

It seems that a quick fix is to replace:

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

by

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

But I don't know where this bug come from

@arthurdouillard
Copy link
Collaborator

The bug came from split_train_val, I've fixed it.

@lebrice you can now update to 1.0.10. Sorry for the inconvenience.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants