-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add best_k_metrics
parameter to the ModelCheckpoint
#20457
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
Open
gonzachiar
wants to merge
8
commits into
Lightning-AI:master
Choose a base branch
from
gonzachiar:feature/best-k-metrics
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8df37c2
add best_k_metrics parameter
gonzachiar 32db7d4
Merge branch 'master' into feature/best-k-metrics
lantiga 0b3322d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 74cf6a7
Merge branch 'master' into feature/best-k-metrics
Borda a214154
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 835538c
Merge branch 'master' into feature/best-k-metrics
Borda 80c4bb6
fix: modify and sort imports
gonzachiar 821bfef
fix: revert changes on best_k_models
gonzachiar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,6 @@ | |
from torch import optim | ||
from torch.utils.data.dataloader import DataLoader | ||
|
||
import lightning.pytorch as pl | ||
from lightning.fabric.utilities.cloud_io import _load as pl_load | ||
from lightning.pytorch import Trainer, seed_everything | ||
from lightning.pytorch.callbacks import ModelCheckpoint | ||
|
@@ -703,6 +702,7 @@ def test_model_checkpoint_save_last_none_monitor(tmp_path, caplog): | |
assert checkpoint_callback.best_model_path == str(tmp_path / "epoch=1-step=20.ckpt") | ||
assert checkpoint_callback.last_model_path == str(tmp_path / "last.ckpt") | ||
assert checkpoint_callback.best_model_score is None | ||
assert checkpoint_callback.best_model_metrics is None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need to add tests that exercise the new code |
||
assert checkpoint_callback.best_k_models == {} | ||
assert checkpoint_callback.kth_best_model_path == "" | ||
|
||
|
@@ -809,6 +809,7 @@ def test_model_checkpoint_topk_zero(tmp_path): | |
assert checkpoint_callback.monitor is None | ||
assert checkpoint_callback.best_model_path == "" | ||
assert checkpoint_callback.best_model_score is None | ||
assert checkpoint_callback.best_model_metrics is None | ||
assert checkpoint_callback.best_k_models == {} | ||
assert checkpoint_callback.kth_best_model_path == "" | ||
# check that only the last ckpt was created | ||
|
@@ -1074,7 +1075,7 @@ def assert_checkpoint_log_dir(idx): | |
|
||
# load from checkpoint | ||
trainer_config["logger"] = TensorBoardLogger(tmp_path) | ||
trainer = pl.Trainer(**trainer_config) | ||
trainer = Trainer(**trainer_config) | ||
assert_trainer_init(trainer) | ||
|
||
model = ExtendedBoringModel() | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.