Skip to content

EarlyStopping for KFold Cross-validation #22

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
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Jocareher
Copy link

I've been using this EarlyStopping class for my master's thesis project, but I had to modify it slightly to save the model with the lowest val_loss for a given fold when doing kfold cross-validation.
So, it works the same way as the original class, the difference is that it monitors the val_loss for each of the folds and saves k different models (one per fold), on a given path.
On each fold, the object is reset to monitor the val_loss starting from inf-->fold_val_loss and it creates the filename with the following format: "../checkpoint_fold_{fold_number}.pt"

Also, I added comments, to the original class and black formatted the script.

Finally, I updated the .gitignore file to ignore the .DS_Store files that are automatically created in MacOS.

I hope you find this update as helpful as your work has been to me. :D

@Bjarten Bjarten deleted the branch Bjarten:main October 14, 2024 03:52
@Bjarten Bjarten closed this Oct 14, 2024
@Bjarten Bjarten reopened this Oct 14, 2024
@Bjarten Bjarten changed the base branch from master to main October 14, 2024 04:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants