You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that autoreload fails when updating class methods in the api_overview.ipynb, and that this can be fixed by removing the explicit child class parameter in the super()__init__() call. In my case, I was debugging an updated TrainingPlan, but I suspect this will be effective for other classes as well.
I can submit a PR for this but wanted to make sure it wasn't already being addressed somehow.
add a cell in api_overview.ipynb with
%load_extautoreload%autoreload2
instantiate and train the model
introduce a bug (eg in train.TrainingPlan, inherited by the already-instantiated model) like:
deftraining_step(self, batch, batch_idx, optimizer_idx=0):
if"kl_weight"inself.loss_kwargs:
self.loss_kwargs.update({"kl_weight": self.kl_weight})
_, _, scvi_loss=self.forward(batch, loss_kwargs=self.loss_kwargs)
self.log("train_loss", scvi_loss_not_defined.loss, on_epoch=True) # this will cause an errorself.compute_and_log_metrics(scvi_loss, self.train_metrics, "train")
returnscvi_loss.loss
which tries to log an undefined key and gives the following error
mkarikom
changed the title
bug and possible fix for autoreload error caused by explicit module.super(ChildClass,self)__init__()
report [and proposed fix] for autoreload error caused by explicit module.super(ChildClass,self)__init__()
Sep 13, 2022
I'm not sure I understand why this is the fix, but I do agree we should use super().__init__() everywhere. A PR changing all super calls codebase-wide with just super() would be appreciated.
I noticed that autoreload fails when updating class methods in the api_overview.ipynb, and that this can be fixed by removing the explicit child class parameter in the
super()__init__()
call. In my case, I was debugging an updated TrainingPlan, but I suspect this will be effective for other classes as well.I can submit a PR for this but wanted to make sure it wasn't already being addressed somehow.
api_overview.ipynb
withmodel
train.TrainingPlan
, inherited by the already-instantiatedmodel
) like:which tries to log an undefined key and gives the following error
train/_trainingplans.py
:154 so thattrain.TrainingPlan.__init__()
callsinit()
on the parent implicitly like:model
, re-runmodel.train(max_epochs=4)
, and notice that our fix in (4) is reloaded successfully:Versions:
The text was updated successfully, but these errors were encountered: