Shortcuts

OnExceptionCheckpoint

class lightning.pytorch.callbacks.OnExceptionCheckpoint(dirpath, filename='on_exception')[source]

Bases: lightning.pytorch.callbacks.checkpoint.Checkpoint

Used to save a checkpoint on exception.

Parameters
  • dirpath (Union[str, Path]) – directory to save the checkpoint file.

  • filename (str) – checkpoint filename. This must not include the extension.

Raises

ValueError – If filename is empty.

Example

>>> from lightning.pytorch import Trainer
>>> from lightning.pytorch.callbacks import OnExceptionCheckpoint
>>> trainer = Trainer(callbacks=[OnExceptionCheckpoint(".")])
on_exception(trainer, *_, **__)[source]

Called when any trainer execution is interrupted by an exception.

Return type

None

teardown(trainer, *_, **__)[source]

Called when fit, validate, test, predict, or tune ends.

Return type

None