Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Use master branch of unsup_vvs #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

mschrimpf
Copy link
Member

@mschrimpf mschrimpf commented Apr 7, 2021

@chengxuz said he has been using the master branch and not the bs_latest branch.

@mschrimpf
Copy link
Member Author

re-opening due to timeout

@mschrimpf mschrimpf closed this Apr 8, 2021
@mschrimpf mschrimpf reopened this Apr 8, 2021
@mschrimpf
Copy link
Member Author

seems to run into

tests/base_models/test___init__.py:14: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/om2/group/dicarlo/jenkins/miniconda3/envs/candidate_models_unittests_114/lib/python3.7/site-packages/brainscore/utils/__init__.py:80: in __call__
    return self.content(*args, **kwargs)
/om2/group/dicarlo/jenkins/miniconda3/envs/candidate_models_unittests_114/lib/python3.7/site-packages/model_tools/activations/tensorflow.py:25: in __call__
    return self._extractor(*args, **kwargs)
/om2/group/dicarlo/jenkins/miniconda3/envs/candidate_models_unittests_114/lib/python3.7/site-packages/model_tools/activations/core.py:43: in __call__
    return self.from_paths(stimuli_paths=stimuli, layers=layers, stimuli_identifier=stimuli_identifier)
/om2/group/dicarlo/jenkins/miniconda3/envs/candidate_models_unittests_114/lib/python3.7/site-packages/model_tools/activations/core.py:73: in from_paths
    activations = fnc(layers=layers, stimuli_paths=reduced_paths)
/om2/group/dicarlo/jenkins/miniconda3/envs/candidate_models_unittests_114/lib/python3.7/site-packages/model_tools/activations/core.py:83: in _from_paths
    layer_activations = self._get_activations_batched(stimuli_paths, layers=layers, batch_size=self._batch_size)
/om2/group/dicarlo/jenkins/miniconda3/envs/candidate_models_unittests_114/lib/python3.7/site-packages/model_tools/activations/core.py:132: in _get_activations_batched
    batch_activations = self._get_batch_activations(batch_inputs, layer_names=layers, batch_size=batch_size)
/om2/group/dicarlo/jenkins/miniconda3/envs/candidate_models_unittests_114/lib/python3.7/site-packages/model_tools/activations/core.py:147: in _get_batch_activations
    activations = self.get_activations(preprocessed_inputs, layer_names)
/om2/group/dicarlo/jenkins/miniconda3/envs/candidate_models_unittests_114/lib/python3.7/site-packages/model_tools/activations/tensorflow.py:49: in get_activations
    layer_outputs = super(TensorflowSlimWrapper, self).get_activations(images, layer_names)
/om2/group/dicarlo/jenkins/miniconda3/envs/candidate_models_unittests_114/lib/python3.7/site-packages/model_tools/activations/tensorflow.py:30: in get_activations
    for layer in layer_names)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

.0 = <list_iterator object at 0x2b48f5ce0150>

    layer_tensors = OrderedDict((layer, self._endpoints[
        layer if (layer != 'logits' or layer in self._endpoints) else next(reversed(self._endpoints))])
>                               for layer in layer_names)
E   TypeError: 'dict' object is not reversible

@RylanSchaeffer
Copy link

RylanSchaeffer commented Sep 23, 2022

@chengxuz @mschrimpf I went to open a PR with this PR's exact change. Is the above error still an issue? I'm running my own check that unsup_vvs's master branch works, but I don't know how to trigger these unit tests.

@chengxuz
Copy link
Collaborator

This looks like a very general error to me saying that self._endpoints needs to support reversed, which is not possible for typical dict, but maybe possible for OrderedDict? @mschrimpf , can you confirm this observation? What would be the best fix for this?

@mschrimpf
Copy link
Member Author

mschrimpf commented Sep 24, 2022

@chengxuz yes I think that's right. The issue is that it's asked to output the logits layer (from this unit test) and if that name is not in the endpoints, it attempts to use the last layer of the endpoints as the logits

@chengxuz
Copy link
Collaborator

OK, I believe I have fixed this issue in the latest commit to unsup_vvs master branch.

@mschrimpf
Copy link
Member Author

Looks like tests are failing with the same message still:

    layer_tensors = OrderedDict((layer, self._endpoints[
        layer if (layer != 'logits' or layer in self._endpoints) else next(reversed(self._endpoints))])
>                               for layer in layer_names)
E   TypeError: 'dict' object is not reversible

image

@chengxuz
Copy link
Collaborator

Can I ask what would be the minimal test command I can use to reproduce this error?

@mschrimpf
Copy link
Member Author

Can I ask what would be the minimal test command I can use to reproduce this error?

It's a subset of the tests in test_run_logits, i.e. pytest tests/base_models/test___init__.py::test_run_logits. You can specify the model list at the top of the test to include only your unsupervised models.

@chengxuz
Copy link
Collaborator

chengxuz commented Oct 3, 2022

I have updated the unsup_vvs master branch to fix the failure for all the models except two models resnet18-deepcluster and resnet18-contrastive_multiview. You can first check whether that's true on your end. FYI, even before my update today, the model resnet18-simlcr should work, so I am guessing that you may not be using the latest master branch in your test as it showed that resnet18-simlcr did not work.

As for the two models left, there is a general issue with these models, which is in fact related to an issue I also had earlier this year and I asked you and Mike but never got it solved. The issue is that they are pytorch models without logits layer, which makes the default layer choice wrong (see here). How should we address this issue? Why not getting the layer from the model's possible layers? This would require some non-trivial changes to this model_tools core file, but should be doable.

@mschrimpf
Copy link
Member Author

I'll re-trigger unit tests with your updated repository

@mschrimpf mschrimpf closed this Oct 11, 2022
@mschrimpf mschrimpf reopened this Oct 11, 2022
@mschrimpf
Copy link
Member Author

@RylanSchaeffer what do you think? Do the models work on your end?

@RylanSchaeffer
Copy link

@mschrimpf thanks for asking. I finally was able to circle back to this, and I'm getting the following error:

Unable to find module for VVS identifier: resnet18-simclr

@RylanSchaeffer
Copy link

RylanSchaeffer commented Nov 12, 2022

@chengxuz , I believe I'm running master from unsup_vvs. I just tried installing again to check and the commit hash seems to match the latest master (6bd9e87e987fe15d79f95196f53e909848670826):

$ pip install "unsup_vvs @ git+https://github.com/neuroailab/unsup_vvs.git"
Collecting unsup_vvs@ git+https://github.com/neuroailab/unsup_vvs.git
  Cloning https://github.com/neuroailab/unsup_vvs.git to /tmp/pip-install-d4raq0vf/unsup-vvs_f057fb77b3fa4685b189b8a2708460a0
  Running command git clone --filter=blob:none --quiet https://github.com/neuroailab/unsup_vvs.git /tmp/pip-install-d4raq0vf/unsup-vvs_f057fb77b3fa4685b189b8a2708460a0
  Resolved https://github.com/neuroailab/unsup_vvs.git to commit 6bd9e87e987fe15d79f95196f53e909848670826
  Preparing metadata (setup.py) ... done
Requirement already satisfied: dotmap in ./regdim_venv/lib/python3.7/site-packages (from unsup_vvs@ git+https://github.com/neuroailab/unsup_vvs.git) (1.3.30)
Requirement already satisfied: scikit-image in ./regdim_venv/lib/python3.7/site-packages (from unsup_vvs@ git+https://github.com/neuroailab/unsup_vvs.git) (0.14.5)
Requirement already satisfied: matplotlib>=2.0.0 in ./regdim_venv/lib/python3.7/site-packages (from scikit-image->unsup_vvs@ git+https://github.com/neuroailab/unsup_vvs.git) (3.5.3)
Requirement already satisfied: scipy>=0.17.0 in ./regdim_venv/lib/python3.7/site-packages (from scikit-image->unsup_vvs@ git+https://github.com/neuroailab/unsup_vvs.git) (1.7.3)
Requirement already satisfied: pillow>=4.3.0 in ./regdim_venv/lib/python3.7/site-packages (from scikit-image->unsup_vvs@ git+https://github.com/neuroailab/unsup_vvs.git) (8.4.0)
Requirement already satisfied: PyWavelets>=0.4.0 in ./regdim_venv/lib/python3.7/site-packages (from scikit-image->unsup_vvs@ git+https://github.com/neuroailab/unsup_vvs.git) (1.3.0)
Requirement already satisfied: six>=1.10.0 in ./regdim_venv/lib/python3.7/site-packages (from scikit-image->unsup_vvs@ git+https://github.com/neuroailab/unsup_vvs.git) (1.16.0)
Requirement already satisfied: networkx>=1.8 in ./regdim_venv/lib/python3.7/site-packages (from scikit-image->unsup_vvs@ git+https://github.com/neuroailab/unsup_vvs.git) (1.11)
Requirement already satisfied: cloudpickle>=0.2.1 in ./regdim_venv/lib/python3.7/site-packages (from scikit-image->unsup_vvs@ git+https://github.com/neuroailab/unsup_vvs.git) (2.2.0)
Requirement already satisfied: fonttools>=4.22.0 in ./regdim_venv/lib/python3.7/site-packages (from matplotlib>=2.0.0->scikit-image->unsup_vvs@ git+https://github.com/neuroailab/unsup_vvs.git) (4.38.0)
Requirement already satisfied: numpy>=1.17 in ./regdim_venv/lib/python3.7/site-packages (from matplotlib>=2.0.0->scikit-image->unsup_vvs@ git+https://github.com/neuroailab/unsup_vvs.git) (1.21.6)
Requirement already satisfied: packaging>=20.0 in ./regdim_venv/lib/python3.7/site-packages (from matplotlib>=2.0.0->scikit-image->unsup_vvs@ git+https://github.com/neuroailab/unsup_vvs.git) (21.3)
Requirement already satisfied: pyparsing>=2.2.1 in ./regdim_venv/lib/python3.7/site-packages (from matplotlib>=2.0.0->scikit-image->unsup_vvs@ git+https://github.com/neuroailab/unsup_vvs.git) (3.0.9)
Requirement already satisfied: python-dateutil>=2.7 in ./regdim_venv/lib/python3.7/site-packages (from matplotlib>=2.0.0->scikit-image->unsup_vvs@ git+https://github.com/neuroailab/unsup_vvs.git) (2.8.2)
Requirement already satisfied: kiwisolver>=1.0.1 in ./regdim_venv/lib/python3.7/site-packages (from matplotlib>=2.0.0->scikit-image->unsup_vvs@ git+https://github.com/neuroailab/unsup_vvs.git) (1.4.4)
Requirement already satisfied: cycler>=0.10 in ./regdim_venv/lib/python3.7/site-packages (from matplotlib>=2.0.0->scikit-image->unsup_vvs@ git+https://github.com/neuroailab/unsup_vvs.git) (0.11.0)
Requirement already satisfied: decorator>=3.4.0 in ./regdim_venv/lib/python3.7/site-packages (from networkx>=1.8->scikit-image->unsup_vvs@ git+https://github.com/neuroailab/unsup_vvs.git) (5.1.1)
Requirement already satisfied: typing-extensions in ./regdim_venv/lib/python3.7/site-packages (from kiwisolver>=1.0.1->matplotlib>=2.0.0->scikit-image->unsup_vvs@ git+https://github.com/neuroailab/unsup_vvs.git) (4.4.0)

@mschrimpf
Copy link
Member Author

I'm getting the following error:

Unable to find module for VVS identifier: resnet18-simclr

Do the other models all work? Maybe @chengxuz can chime in whether the simclr version has vanished from the repository.

@RylanSchaeffer
Copy link

RylanSchaeffer commented Nov 12, 2022 via email

@RylanSchaeffer
Copy link

RylanSchaeffer commented Nov 13, 2022

One error:

  File "/home/gridsan/rschaeffer/FieteLab-Reg-Eff-Dim/regdim_venv/lib/python3.7/site-packages/unsup_vvs/neural_fit/cleaned_network_builder.py", line 22, in get_simclr_ending_points
    from unsup_vvs.network_training.models.simclr import resnet
ModuleNotFoundError: No module named 'unsup_vvs.network_training.models.simclr'

I'm also getting the following error - is a specific torchvision version required?

    from unsup_vvs.neural_fit.pt_scripts.la_cmc_resnet import ResNetLabV1
  File "/home/gridsan/rschaeffer/FieteLab-Reg-Eff-Dim/regdim_venv/lib/python3.7/site-packages/unsup_vvs/neural_fit/pt_scripts/la_cmc_resnet.py", line 8, in <module>
    from torchvision.models.utils import load_state_dict_from_url
ModuleNotFoundError: No module named 'torchvision.models.utils' 

I'm on torchvision 0.13.1.

@RylanSchaeffer
Copy link

This looks relevant: https://stackoverflow.com/questions/70998767/no-module-named-torchvision-models-utils

@chengxuz , is there a particular required torchvision version I should be using? I looked inside unsup-vvs and didn't see anything, but I might've missed it

@chengxuz
Copy link
Collaborator

For the simclr model importing, I can do that on my end. The folder definitely exists in the repo (see here). I don't understand why it fails for you. Can you try to clone the repo and just install it in dev mode (pip install -e .)?

For the version of torchvision, the 0.13.1 is indeed later than what I was using (0.6.0). This looks like a backward compatibility issue for pytorch. Can you try the earlier version?

@RylanSchaeffer
Copy link

RylanSchaeffer commented Nov 15, 2022 via email

@RylanSchaeffer
Copy link

Cloning and installing with pip install -e . worked! Thank you for that!!

@RylanSchaeffer
Copy link

Switching to 0.6.0 also forced me to downgrade to torch 1.5, which created a new error:

python3.7/site-packages/torchvision/models/resnet.py", line 224, in _resnet
    model = ResNet(block, layers, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'weights'

I went back to torch 1.12 and now get error:

ImportError: cannot import name 'ResNet18_Weights' from 'torchvision.models'

@RylanSchaeffer
Copy link

Can I trouble one of you two to please clarify exactly which versions of which libraries I want to be running?

@chengxuz
Copy link
Collaborator

OK, let's schedule a time to chat.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants