royerlab / cytoself

Self-supervised models for encoding protein localization patterns from microscopy images

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Early stopping does not count consecutive steps on pytorch branch

jmhb0 opened this issue · comments

commented

Hey Hiro,

The paper says this about early stopping:

training was terminated when the validation loss did not improve for more than 12 consecutive epochs.

Here is the relevant code in cytoself/trainer/basetrainer.py

  if _vloss < best_vloss:
      best_vloss = _vloss
      self.best_model = deepcopy(self.model)
      # Save the best model checkpoint
      self.save_checkpoint()
  else:
      count_lr_no_improve += 1
      count_early_stop += 1

I believe you need to add count_early_stop=0 in the if branch to reset the counter.

Hi @jmhb0 sorry for my late reply and thank you for the bug report!
Yes, you're right and I have pushed a fix for this issue.

Thanks !