Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Add note about version counter in ModelCheckpoint #20146

Merged
merged 8 commits into from
Aug 4, 2024
12 changes: 12 additions & 0 deletions src/lightning/pytorch/callbacks/model_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ class ModelCheckpoint(Checkpoint):
If ``save_top_k >= 2`` and the callback is called multiple times inside an epoch, and the filename remains
unchanged, the name of the saved file will be appended with a version count starting with ``v1`` to avoid
collisions unless ``enable_version_counter`` is set to False.
adosar marked this conversation as resolved.
Show resolved Hide resolved

.. note::

**You should not rely on the appended version to retrieve the
best k model**, since there is no relationship between version
count and model performance. For example, ``filename-v2.ckpt``
doesn't necessarily correspond to the 2nd best model.

The versioning is only there to prevent overwriting files. **It is recommended
that you pass formatting options to** ``filename``, **so the best k models can
be easily retrieved.** Otherwise, all checkpoints must be loaded and checked.
adosar marked this conversation as resolved.
Show resolved Hide resolved

mode: one of {min, max}.
If ``save_top_k != 0``, the decision to overwrite the current save file is made
based on either the maximization or the minimization of the monitored quantity.
Expand Down
Loading