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

Error when making new CPC_v2 model #679

Closed
shatz01 opened this issue Jul 1, 2021 · 3 comments · Fixed by #680
Closed

Error when making new CPC_v2 model #679

shatz01 opened this issue Jul 1, 2021 · 3 comments · Fixed by #680
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@shatz01
Copy link
Contributor

shatz01 commented Jul 1, 2021

🐛 Bug

Missing Attribute "encoder" error when creating new CPC_v2 model.
Same code is shown in docs here: https://lightning-bolts.readthedocs.io/en/latest/self_supervised_models.html#research

To Reproduce

Steps to reproduce the behavior:

Run:

from pl_bolts.models.self_supervised import CPC_v2
from pl_bolts.losses.self_supervised_learning import FeatureMapContrastiveTask

amdim_task = FeatureMapContrastiveTask(comparisons='01, 11, 02', bidirectional=True)
model = CPC_v2(contrastive_task=amdim_task)

Error:

Traceback (most recent call last):                                                                                                                                                        
  File "/home/shatz/miniconda3/envs/fix_lightning/lib/python3.9/site-packages/pytorch_lightning/utilities/parsing.py", line 250, in __getattr__                                           
    return self[key]                                                                                                                                                                      
KeyError: 'encoder'                                                                                                                                                                       
                                                                                                                                                                                          
The above exception was the direct cause of the following exception:                                                                                                                      
                                                                                                                                                                                          
Traceback (most recent call last):                                                                                                                                                        
  File "/home/shatz/Documents/lightning-bolts/mytest.py", line 6, in <module>                                                                                                             
    model = CPC_v2(contrastive_task=amdim_task)                                                                                                                                           
  File "/home/shatz/Documents/lightning-bolts/pl_bolts/models/self_supervised/cpc/cpc_module.py", line 72, in __init__                                                                    
    c, h = self.__compute_final_nb_c(patch_size)                                                                                                                                          
  File "/home/shatz/Documents/lightning-bolts/pl_bolts/models/self_supervised/cpc/cpc_module.py", line 103, in __compute_final_nb_c                                                       
    if self.hparams.encoder != 'cpc_encoder':                                                                                                                                             
  File "/home/shatz/miniconda3/envs/fix_lightning/lib/python3.9/site-packages/pytorch_lightning/utilities/parsing.py", line 252, in __getattr__                                           
    raise AttributeError(f'Missing attribute "{key}"') from exp                                                                                                                           
AttributeError: Missing attribute "encoder" 

Expected behavior

No errors.

Environment

  • Ubuntu
  • Anaconda
  • Python version: 3.9.5
  • CUDA/cuDNN version: V10.1.243
  • GPU models and configuration: RTX2070

Additional context

The code is from the docs: https://lightning-bolts.readthedocs.io/en/latest/self_supervised_models.html#research

@shatz01 shatz01 added fix fixing issues... help wanted Extra attention is needed labels Jul 1, 2021
@github-actions
Copy link

github-actions bot commented Jul 1, 2021

Hi! thanks for your contribution!, great first issue!

@shatz01
Copy link
Contributor Author

shatz01 commented Jul 1, 2021

Fixed in Pull Request #680

@shatz01
Copy link
Contributor Author

shatz01 commented Jul 1, 2021

Also its my first time contributing to a big project. Please let me know if I should do anything different.

@Borda Borda mentioned this issue Jul 1, 2021
5 tasks
@Borda Borda closed this as completed in #680 Jul 4, 2021
@Borda Borda added bug Something isn't working and removed fix fixing issues... labels Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants