scvi.external.decipher._trainingplan.DecipherTrainingPlan#

class scvi.external.decipher._trainingplan.DecipherTrainingPlan(pyro_module, loss_fn=None, optim=None, optim_kwargs=None)[source]#

Bases: PyroTrainingPlan

Lightning module task to train the Decipher Pyro module.

Parameters:
  • pyro_module (PyroBaseModuleClass) – An instance of PyroBaseModuleClass. This object should have callable model and guide attributes or methods.

  • loss_fn (ELBO | None (default: None)) – A Pyro loss. Should be a subclass of ELBO. If None, defaults to Trace_ELBO.

  • optim (PyroOptim | None (default: None)) – A Pyro optimizer instance, e.g., Adam(). If None, defaults to Adam() optimizer with a learning rate of 1e-3.

  • optim_kwargs (dict | None (default: None)) – Keyword arguments for default optimiser Adam().

Attributes table#

Methods table#

backward(*args, **kwargs)

No-op, as Pyro computes the gradients inside the training step.

configure_optimizers()

Shim optimizer for PyTorch Lightning.

on_train_epoch_end()

Training epoch end for Pyro training.

on_validation_epoch_end()

Validation epoch end for Pyro training.

on_validation_model_train()

Prepare the model for validation by switching to train mode.

optimizer_step(*args, **kwargs)

No-op, as the Pyro optimizer steps inside the training step.

training_step(batch, batch_idx)

Training step for Pyro training.

validation_step(batch, batch_idx)

Validation step for Pyro training.

Attributes#

DecipherTrainingPlan.training: bool#

Methods#

DecipherTrainingPlan.backward(*args, **kwargs)[source]#

No-op, as Pyro computes the gradients inside the training step.

DecipherTrainingPlan.configure_optimizers()[source]#

Shim optimizer for PyTorch Lightning.

PyTorch Lightning wants to take steps on an optimizer returned by this function in order to increment the global step count. See PyTorch Lighinting optimizer manual loop.

Here we provide a shim optimizer that we can take steps on at minimal computational cost in order to keep Lightning happy :).

DecipherTrainingPlan.on_train_epoch_end()[source]#

Training epoch end for Pyro training.

DecipherTrainingPlan.on_validation_epoch_end()[source]#

Validation epoch end for Pyro training.

DecipherTrainingPlan.on_validation_model_train()[source]#

Prepare the model for validation by switching to train mode.

DecipherTrainingPlan.optimizer_step(*args, **kwargs)[source]#

No-op, as the Pyro optimizer steps inside the training step.

DecipherTrainingPlan.training_step(batch, batch_idx)[source]#

Training step for Pyro training.

DecipherTrainingPlan.validation_step(batch, batch_idx)[source]#

Validation step for Pyro training.