Skip to content

Commit

Permalink
Merge pull request #584 from Hongyu-yu/main
Browse files Browse the repository at this point in the history
Fix bug about undefined swa
  • Loading branch information
ilyes319 authored Sep 12, 2024
2 parents 6d768c2 + dcaa0ae commit d950e18
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions mace/tools/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,16 +279,17 @@ def train(
if rank == 0:
if valid_loss >= lowest_loss:
patience_counter += 1
if patience_counter >= patience and epoch < swa.start:
logging.info(
f"Stopping optimization after {patience_counter} epochs without improvement and starting Stage Two"
)
epoch = swa.start
elif patience_counter >= patience and epoch >= swa.start:
logging.info(
f"Stopping optimization after {patience_counter} epochs without improvement"
)
break
if patience_counter >= patience:
if swa is not None and epoch < swa.start:
logging.info(
f"Stopping optimization after {patience_counter} epochs without improvement and starting Stage Two"
)
epoch = swa.start
else:
logging.info(
f"Stopping optimization after {patience_counter} epochs without improvement"
)
break
if save_all_checkpoints:
param_context = (
ema.average_parameters()
Expand Down

0 comments on commit d950e18

Please sign in to comment.