Skip to content

Commit

Permalink
added saving latest model when keyboard interrupt during training laat
Browse files Browse the repository at this point in the history
  • Loading branch information
pokarats committed Jan 24, 2023
1 parent 1915540 commit bc87e1c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/models/train_eval_laat.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ def train(
except KeyboardInterrupt:
print('*' * 20)
print('Exiting from training early')
if not (MODEL_FOLDER / f"best_{model_save_fname}.pt").exists():
logger.info(f"saving best model so far from current epoch...")
torch.save(model.state_dict(), f"{MODEL_FOLDER / f'best_{model_save_fname}.pt'}")
return evals

return evals

Expand Down

0 comments on commit bc87e1c

Please sign in to comment.