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

early-stopping-pytorch.py, shouldn't the script save previous model? #17

Open
brucewlee opened this issue May 29, 2022 · 1 comment
Open

Comments

@brucewlee
Copy link

Hi. Thanks for your resources :) They are giving great help to my research.

BTW, isn't it correct to save the previous model when the loss decreases? It seems like your current early-stopping-pytorch.py script is intended to save the current model, not the previous one.

@bioinformatica
Copy link

self.best_score = score
self.save_checkpoint(val_loss, model)

def save_checkpoint(self, val_loss, model):
'''Saves model when validation loss decrease.'''
if self.verbose:
self.trace_func(f'Validation loss decreased ({self.val_loss_min:.6f} --> {val_loss:.6f}). Saving model ...')
torch.save(model.state_dict(), self.path)

save the best model

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

No branches or pull requests

2 participants