Skip to content

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
@Bjarten Bjarten closed this Nov 11, 2025
@Bjarten Bjarten reopened this Nov 11, 2025
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