scvi.train.SaveBestState#

class scvi.train.SaveBestState(monitor='elbo_validation', mode='min', verbose=False, period=1)[source]#

Bases: Callback

Save the best module state and restore into model.

Parameters:
monitor : str (default: 'elbo_validation')

quantity to monitor.

verbose

verbosity, True or False.

mode : str (default: 'min')

one of [“min”, “max”].

period

Interval (number of epochs) between checkpoints.

Examples

from scvi.train import Trainer from scvi.train import SaveBestState

Attributes table#

Methods table#

check_monitor_top(current)

on_epoch_end(trainer, pl_module)

Deprecated since version v1.6.

on_train_end(trainer, pl_module)

Called when the train ends.

on_train_start(trainer, pl_module)

Called when the train begins.

Attributes#

state_key#

SaveBestState.state_key[source]#

Identifier for the state of the callback.

Used to store and retrieve a callback’s state from the checkpoint dictionary by checkpoint["callbacks"][state_key]. Implementations of a callback need to provide a unique state key if 1) the callback has state and 2) it is desired to maintain the state of multiple instances of that callback.

Return type:

str

Methods#

check_monitor_top#

SaveBestState.check_monitor_top(current)[source]#

on_epoch_end#

SaveBestState.on_epoch_end(trainer, pl_module)[source]#

Deprecated since version v1.6: This callback hook was deprecated in v1.6 and will be removed in v1.8. Use on_<train/validation/test>_epoch_end instead.

Called when either of train/val/test epoch ends.

on_train_end#

SaveBestState.on_train_end(trainer, pl_module)[source]#

Called when the train ends.

on_train_start#

SaveBestState.on_train_start(trainer, pl_module)[source]#

Called when the train begins.