early-stopping-pytorch
early-stopping-pytorch copied to clipboard
early-stopping-pytorch.py, shouldn't the script save previous model?
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.
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