diff --git a/docs/source/trainer.rst b/docs/source/trainer.rst index a11eaceee10c9..563234757995c 100644 --- a/docs/source/trainer.rst +++ b/docs/source/trainer.rst @@ -580,9 +580,18 @@ You can override the default behavior by initializing the :class:`~pytorch_light callback, and adding it to the :paramref:`~pytorch_lightning.trainer.trainer.Trainer.callbacks` list. See :ref:`Saving and Loading Weights ` for how to customize checkpointing. +.. testcode:: + + from pytorch_lightning.callbacks import ModelCheckpoint + # Init ModelCheckpoint callback, monitoring 'val_loss' + checkpoint_callback = ModelCheckpoint(monitor='val_loss') + + # Add your callback to the callbacks list + trainer = Trainer(callbacks=[checkpoint_callback]) + .. warning:: Passing a ModelCheckpoint instance to this argument is deprecated since - v1.1.0 and will be unsupported from v1.3.0. + v1.1 and will be unsupported from v1.3. Use `callbacks` argument instead. default_root_dir diff --git a/pytorch_lightning/trainer/connectors/callback_connector.py b/pytorch_lightning/trainer/connectors/callback_connector.py index c9ef4ae32be77..0f642d26a1157 100644 --- a/pytorch_lightning/trainer/connectors/callback_connector.py +++ b/pytorch_lightning/trainer/connectors/callback_connector.py @@ -59,7 +59,8 @@ def configure_checkpoint_callbacks(self, checkpoint_callback: Union[ModelCheckpo # TODO: deprecated, remove this block in v1.3.0 rank_zero_warn( "Passing a ModelCheckpoint instance to Trainer(checkpoint_callbacks=...)" - " is deprecated since v1.1 and will no longer be supported in v1.3.", + " is deprecated since v1.1 and will no longer be supported in v1.3." + " Use `callbacks` argument instead.", DeprecationWarning ) self.trainer.callbacks.append(checkpoint_callback) diff --git a/pytorch_lightning/trainer/trainer.py b/pytorch_lightning/trainer/trainer.py index 323a758106a32..92f34955c7fce 100644 --- a/pytorch_lightning/trainer/trainer.py +++ b/pytorch_lightning/trainer/trainer.py @@ -179,7 +179,7 @@ def __init__( :paramref:`~pytorch_lightning.trainer.trainer.Trainer.callbacks`. Default: ``True``. .. warning:: Passing a ModelCheckpoint instance to this argument is deprecated since - v1.1.0 and will be unsupported from v1.3.0. + v1.1 and will be unsupported from v1.3. Use `callbacks` argument instead. check_val_every_n_epoch: Check val every n train epochs.