PEAKVI.train(max_epochs=500, lr=0.0001, use_gpu=None, train_size=0.9, validation_size=None, batch_size=128, weight_decay=0.001, eps=1e-08, early_stopping=True, early_stopping_patience=50, save_best=True, check_val_every_n_epoch=None, n_steps_kl_warmup=None, n_epochs_kl_warmup=50, plan_kwargs=None, **kwargs)[source]

Trains the model using amortized variational inference.

max_epochs : intint (default: 500)

Number of passes through the dataset.

lr : floatfloat (default: 0.0001)

Learning rate for optimization.

use_gpu : str | int | bool | NoneUnion[str, int, bool, None] (default: None)

Use default GPU if available (if None or True), or index of GPU to use (if int), or name of GPU (if str, e.g., ‘cuda:0’), or use CPU (if False).

train_size : floatfloat (default: 0.9)

Size of training set in the range [0.0, 1.0].

validation_size : float | NoneOptional[float] (default: None)

Size of the test set. If None, defaults to 1 - train_size. If train_size + validation_size < 1, the remaining cells belong to a test set.

batch_size : intint (default: 128)

Minibatch size to use during training.

weight_decay : floatfloat (default: 0.001)

weight decay regularization term for optimization

eps : floatfloat (default: 1e-08)

Optimizer eps

early_stopping : boolbool (default: True)

Whether to perform early stopping with respect to the validation set.

early_stopping_patience : intint (default: 50)

How many epochs to wait for improvement before early stopping

save_best : boolbool (default: True)

Save the best model state with respect to the validation loss (default), or use the final state in the training procedure

check_val_every_n_epoch : int | NoneOptional[int] (default: None)

Check val every n train epochs. By default, val is not checked, unless early_stopping is True. If so, val is checked every epoch.

n_steps_kl_warmup : int | NoneOptional[int] (default: None)

Number of training steps (minibatches) to scale weight on KL divergences from 0 to 1. Only activated when n_epochs_kl_warmup is set to None. If None, defaults to floor(0.75 * adata.n_obs).

n_epochs_kl_warmup : int | NoneOptional[int] (default: 50)

Number of epochs to scale weight on KL divergences from 0 to 1. Overrides n_steps_kl_warmup when both are not None.

plan_kwargs : dict | NoneOptional[dict] (default: None)

Keyword args for TrainingPlan. Keyword arguments passed to train() will overwrite values present in plan_kwargs, when appropriate.


Other keyword args for Trainer.