Skip to content

AttributeError: 'NoneType' object has no attribute 'encoder' #4

@KhinChoWin-AI

Description

@KhinChoWin-AI

Clustering 15339 samples
num_samples_class=4601
num_samples_class=0
num_samples_class=0
num_samples_class=0
num_samples_class=0
num_samples_class=0
num_samples_class=0
Selected a total of 4601 samples
Using 16bit native Automatic Mixed Precision (AMP)
Trainer already configured with model summary callbacks: [<class 'pytorch_lightning.callbacks.rich_model_summary.RichModelSummary'>]. Skipping setting a default ModelSummary callback.
GPU available: True, used: True
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
HPU available: False, using: 0 HPUs
before init in systems.clup
model: None
╭───────────────────────────── Traceback (most recent call last) ──────────────────────────────╮
│ │
│ /home1/ai20resch16001/anaconda3/lib/python3.9/runpy.py:197 in _run_module_as_main │
│ │
│ 194 │ main_globals = sys.modules["main"].dict
│ 195 │ if alter_argv: │
│ 196 │ │ sys.argv[0] = mod_spec.origin │
│ ❱ 197 │ return _run_code(code, main_globals, None, │
│ 198 │ │ │ │ │ "main", mod_spec) │
│ 199 │
│ 200 def run_module(mod_name, init_globals=None, │
│ /home1/ai20resch16001/anaconda3/lib/python3.9/runpy.py:87 in _run_code │
│ │
│ 84 │ │ │ │ │ loader = loader, │
│ 85 │ │ │ │ │ package = pkg_name, │
│ 86 │ │ │ │ │ spec = mod_spec) │
│ ❱ 87 │ exec(code, run_globals) │
│ 88 │ return run_globals │
│ 89 │
│ 90 def _run_module_code(code, init_globals=None, │
│ │
│ /home1/ai20resch16001/clup/cli/main.py:54 in │
│ │
│ 51 │ │ │ command = COMMANDS.get(key) │
│ 52 │ │ │ if command and value: │
│ 53 │ │ │ │ cmd = command(options, console) │
│ ❱ 54 │ │ │ │ cmd.run() │
│ 55 │ │ │ │ print("after run") │
│ 56 │ │ │ │ executed = True │
│ 57 │ │ │ │ break │
│ │
│ /home1/ai20resch16001/clup/cli/commands/clup.py:143 in run │
│ │
│ 140 │ │ │ criterion_kw["reduction"] = criterion_kw.get("reduction", "batchmean") │
│ 141 │ │ │ criterion = torch.nn.KLDivLoss(**criterion_kw) │
│ 142 │ │ │
│ ❱ 143 │ │ system = CluPSystem( │
│ 144 │ │ │ model, │
│ 145 │ │ │ labels, │
│ 146 │ │ │ labeled_samples=subset_idxs, │
│ │
│ /home1/ai20resch16001/clup/src/systems/clup.py:30 in init
│ │
│ 27 │ ) -> None: │
│ 28 │ │ print("before init in systems.clup") │
│ 29 │ │ print("model: ", model) │
│ ❱ 30 │ │ super().init(model, *args, pseudo_every=1, **kwargs) │
│ 31 │ │ self.labels = labels │
│ 32 │ │ self.labeled_samples: List[int] = labeled_samples or [] │
│ 33 │ │ self.train_criterion = self.criterion │
│ │
│ /home1/ai20resch16001/clup/src/systems/mixins/pseudo_labelling.py:20 in init
│ │
│ 17 │ """Implementation of a mixin for pseudo labelling.""" │
│ 18 │ │
│ 19 │ def init(self, *args, **kwargs) -> None: │
│ ❱ 20 │ │ super().init(*args, **kwargs) │
│ 21 │ │ self.pseudo_labels: Tensor │
│ 22 │ │ self.pseudo_labels_confidence: Tensor │
│ 23 │ │ self.pseudo_every = kwargs.get("pseudo_every", 10) │
│ │
│ /home1/ai20resch16001/clup/src/systems/mixins/mixup.py:13 in init
│ │
│ 10 │ """Implementation of a mixin for mixup.""" │
│ 11 │ │
│ 12 │ def init(self, *args, **kwargs) -> None: │
│ ❱ 13 │ │ super().init(*args, **kwargs) │
│ 14 │ │ self.mixup_alpha = kwargs.get("mixup_alpha", -1) │
│ 15 │ │ self.mixup_last_lambda = -1 │
│ 16 │
│ │
│ /home1/ai20resch16001/clup/src/systems/mixins/base.py:15 in init
│ │
│ 12 │ """Implementation of an abstract mixin class.""" │
│ 13 │ │
│ 14 │ def init(self, *args, **kwargs) -> None: │
│ ❱ 15 │ │ super().init(*args, **kwargs) │
│ 16 │ │ │
│ 17 │ │ if not hasattr(self, "metrics"): │
│ 18 │ │ │ self.metrics: Dict[str, MetricCollection] │
│ │
│ /home1/ai20resch16001/clup/src/systems/classification.py:38 in init
│ │
│ 35 │ │ :param lr: learning rate of the system │
│ 36 │ │ :param lr_scheduler: learning rate policy for training │
│ 37 │ │ """ │
│ ❱ 38 │ │ super().init(model, *args, **kwargs) │
│ 39 │ │ │
│ 40 │ │ self.criterion: Module = torch.nn.CrossEntropyLoss() │
│ 41 │ │ if criterion: │
│ │
│ /home1/ai20resch16001/clup/src/systems/base.py:32 in init
│ │
│ 29 │ │ self.kwargs = kwargs │
│ 30 │ │ self.save_hyperparameters(kwargs) │
│ 31 │ │ │
│ ❱ 32 │ │ print("model.encoder in systems.base#######", model.encoder) │
│ 33 │ │ │
│ 34 │ │ self.encoder = model.encoder │
│ 35 │ │ self.classifier = model.classifier │
╰──────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'NoneType' object has no attribute 'encoder'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions