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"
🐛 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:
Error:
Expected behavior
No errors.
Environment
Additional context
The code is from the docs: https://lightning-bolts.readthedocs.io/en/latest/self_supervised_models.html#research