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

model_checkpoint to save all models (where validation occurs) #1160

Closed
wants to merge 1 commit into from
Closed

model_checkpoint to save all models (where validation occurs) #1160

wants to merge 1 commit into from

Conversation

jamesjjcondon
Copy link
Contributor

Before submitting

What does this PR do?

Improves some use-cases where saving all models is desired. See #596 .
Removes deleting of models on existing save filepath and drops delete warning if save_top_k == -1.
Enables saving of all epochs where validation occurs.
Does not address saving all epochs regardless of check_val_every_n_epochs > 1

Not tested with NVIDIA/apex

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Yes, but 2nd ever contribution (be gentle : )

@codecov
Copy link

codecov bot commented Mar 16, 2020

Codecov Report

Merging #1160 into master will increase coverage by 0%.
The diff coverage is 100%.

@@          Coverage Diff           @@
##           master   #1160   +/-   ##
======================================
  Coverage      93%     93%           
======================================
  Files          61      61           
  Lines        2670    2671    +1     
======================================
+ Hits         2470    2471    +1     
  Misses        200     200           

@Borda
Copy link
Member

Borda commented Mar 16, 2020

this failing shall be fixed in #1163

@Borda
Copy link
Member

Borda commented Mar 17, 2020

@jamesjjcondon could you pls update from master? we have fixed the failier in #1163

@Borda Borda requested a review from jeremyjordan March 18, 2020 13:43
Copy link
Contributor

@jeremyjordan jeremyjordan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @jamesjjcondon thanks for your contribution! just one question

@@ -77,7 +77,7 @@ def __init__(self, filepath, monitor: str = 'val_loss', verbose: bool = False,
save_top_k: int = 1, save_weights_only: bool = False,
mode: str = 'auto', period: int = 1, prefix: str = ''):
super().__init__()
if save_top_k and os.path.isdir(filepath) and len(os.listdir(filepath)) > 0:
if save_top_k > 0 and os.path.isdir(filepath) and len(os.listdir(filepath)) > 0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the motivation for dropping the delete warning if save_top_k == -1?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks to me that we only call _del_model when save_top_k > 0 (lines 225, 226), so I think this is fine currently. We could clear it once if we're saving every epoch though, not sure if that's preferable.

@MattPainter01
Copy link
Contributor

Seems I can't push to this PR (permission denied) to merge in master.

@jamesjjcondon If you could merge it in that would be great.

@mergify mergify bot requested a review from a team March 30, 2020 22:33
@Borda
Copy link
Member

Borda commented Apr 2, 2020

@jamesjjcondon how is it going? could we get this done for next release next week?

@Borda Borda added the feature Is an improvement or enhancement label Apr 2, 2020
@williamFalcon
Copy link
Contributor

Finishing in #1359

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is an improvement or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants