Bjarten / early-stopping-pytorch

Early stopping for PyTorch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Small bug

dagap opened this issue · comments

I think you have a small bug in your code, you need to reset the early_stop variable as:

        self.best_score = score
        self.save_checkpoint(val_loss, model)
        self.counter = 0
        self.early_stop = False  # reset here

Otherwise, if you check this flag from outside, it will possibly stop earlier depending on what happened in the previous iterations.

Sorry my bad.