marrlab / DomainLab

modular domain generalization: https://pypi.org/project/domainlab/

Home Page:https://marrlab.github.io/DomainLab/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

do we need a property for trainer called decoratee (without ""_"") when self.model is always equal to decoratee?

smilesun opened this issue · comments

as in the comment of abstract trainer stated, self.decorates can be both model or trainer but self._decoratee can only be trainer, self.get_model() can only be model

after the change below, now self.model can be both trainer and model

Name  
Latest commitsmilesun2 minutes agoHistoryMerge pull request #823 from marrlab/trainer_as_model4970eb6treat trainer as model

Name
Latest commit
smilesun
smilesun
2 minutes ago
History

Merge pull request #823 from marrlab/trainer_as_model

4970eb6

treat trainer as model

I don't think we need it. Decoratee acts as an abstraction to check if _decoratee is none, and if so accesses the model instead:

@property
def decoratee(self):
if self._decoratee is None:
return self.model
return self._decoratee

However, we are already assigning _decoratee to model in the constructor and could therefore also directly call self.model instead:

if self._decoratee is not None:
self._decoratee.init_business(
model, task, observer, device, aconf, flag_accept
)
self.model = self._decoratee
else:
self.model = model

I don't think this is particularly intuitive because model can then also be a trainer. We could leave the decoratee but rename _decoratee to trainer. That way decoratee could make the distinction between model and trainer and we only access decoratee.