Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

A training error on CIFAR10? #11

Closed
chenfsjz opened this issue Apr 6, 2019 · 7 comments
Closed

A training error on CIFAR10? #11

chenfsjz opened this issue Apr 6, 2019 · 7 comments

Comments

@chenfsjz
Copy link

chenfsjz commented Apr 6, 2019

hi! When I try to retrain the DIM on CIFAR10, there is an issue in the project:

 Traceback (most recent call last):
 File "scripts/deep_infomax.py", line 227, in <module>
   run(DIM())
  File "/usr/local/lib/python3.5/dist-packages/cortex/main.py", line 38, in run
    data.setup(**exp.ARGS['data'])
  File "/usr/local/lib/python3.5/dist-packages/cortex/_lib/data/__init__.py", line 69, in setup
plugin.handle(source, **data_args_)
  File "/usr/local/lib/python3.5/dist-packages/cortex/built_ins/datasets/torchvision_datasets.py", 
line 142, in handle
uniques = sorted(np.unique(labels).tolist())
UnboundLocalError: local variable 'labels' referenced before assignment

I install the cortex as your readme.txt and the version is cortex-0.13, when I check the source code of the specific line in torchvision_datasets.py, there seems the labels is not contained in the CIFAR10 dataset.

train_set, test_set = handler(Dataset, data_path, transform=train_transform, test_transform=test_transform,
                                  labeled_only=labeled_only)
    if train_samples is not None:
        train_set.train_data = train_set.train_data[:train_samples]
        train_set.train_labels = train_set.train_labels[:train_samples]
    if test_samples is not None:
        test_set.test_data = test_set.test_data[:test_samples]
        test_set.test_labels = test_set.test_labels[:test_samples]

    dim_images = train_set[0][0].size()

    if hasattr(train_set, 'labels'):
        labels = train_set.labels
    elif hasattr(train_set, 'targets'):
        labels = train_set.targets

    uniques = sorted(np.unique(labels).tolist())

    if -1 in uniques:
        uniques = uniques[1:]

    dim_l = len(uniques)
    dims = dict(images=dim_images, targets=dim_l)
    input_names = ['images', 'targets', 'index']

    self.add_dataset(
        source,
        data=dict(train=train_set, test=test_set),
        input_names=input_names,
        dims=dims,
        scale=scale
@chenfsjz chenfsjz changed the title An training error? An training error on CIFAR10? Apr 6, 2019
@rdevon
Copy link
Owner

rdevon commented Apr 6, 2019

So the problem is that cortex dev has moved a bit since I last pushed this repo. I'm working on updating DIM, but I ran into some snags that I should be wrapping up this week.

DIM should be up-to-date with the latest cortex later this week, but until then you should be using this commit:
https://github.com/rdevon/cortex/tree/07646b8cde28b898caba649bf1d93719ad539b98

Let me know if that works. I'm making this a priority this week, so at least by the end of the week things should be working again.

@chenfsjz
Copy link
Author

chenfsjz commented Apr 6, 2019

Thanks for your reply, After I install the new version of cortex, there is a new issue as below,

run(DIM())
File "/usr/local/lib/python3.5/dist-packages/cortex/main.py", line 26, in run
  args = setup_cortex(model=model)
File "/usr/local/lib/python3.5/dist-packages/cortex/_lib/__init__.py", line 32, in setup_cortex
 args = parse_args(models.MODEL_PLUGINS, model=model)
File "/usr/local/lib/python3.5/dist-packages/cortex/_lib/parsing.py", line 379, in parse_args
   _parse_model(model, parser)
 File "/usr/local/lib/python3.5/dist-packages/cortex/_lib/parsing.py", line 257, in _parse_model
   _add_default_arguments(key, args, subparser)
 File "/usr/local/lib/python3.5/dist-packages/cortex/_lib/parsing.py", line 273, in 
    _add_default_arguments
help = DEFAULT_HELP[key][k]
KeyError: 'model'

@rdevon
Copy link
Owner

rdevon commented Apr 6, 2019

OK, that's strange. Obviously I need to work out which version is working. I can test this out on Monday (or just push some fixes).

@rdevon
Copy link
Owner

rdevon commented Apr 12, 2019

I've pushed a lot of changes. Things should work now, and there are more features.
e6622e1

Let me know if your problems in this issue are fixed.

@chenfsjz chenfsjz changed the title An training error on CIFAR10? A training error on CIFAR10? Apr 13, 2019
@chenfsjz
Copy link
Author

I guess there is some thing has been missed?

ImportError: No module named 'cortex_DIM.evaluation_models.mine_eval'

so you forgot to upload the mine_eval into the evaluation_models?

@rdevon
Copy link
Owner

rdevon commented Apr 14, 2019

Ah. No I meant to exclude it. Will fix ASAP but weird the error didn't come up for me in a fresh env

@rdevon
Copy link
Owner

rdevon commented Apr 14, 2019

Hopefully 1242330 fixed it. I wont have time to test it until Monday.

@rdevon rdevon closed this as completed Apr 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants