Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions zapbench/ts_forecasting/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,18 +486,18 @@ def train_and_evaluate(
)
train_metrics = None
if config.early_stopping_metric in train_metrics_cpu:
_, early_stop = early_stop.update(
_, early_stop = early_stop.update( # pyrefly: ignore[missing-attribute]
train_metrics_cpu[config.early_stopping_metric], step
)

# Early stopping.
if config.early_stopping and early_stop.should_stop:
if config.early_stopping and early_stop.should_stop: # pyrefly: ignore[missing-attribute]
is_last_step = True
last_step_message = 'Met early stopping criterion at step %d.' % step
logging.info(last_step_message)

# Max runtime stopping.
max_runtime_stop = max_runtime_stop.update()
max_runtime_stop = max_runtime_stop.update() # pyrefly: ignore[missing-attribute]
if config.max_runtime_stopping and max_runtime_stop.should_stop:
is_last_step = True
last_step_message = (
Expand Down Expand Up @@ -553,11 +553,11 @@ def train_and_evaluate(
writer.write_scalars(
step, metrics_lib.make_dict_of_scalars(val_metrics_cpu)
)
track_best_val_loss_step = track_best_val_loss_step.update(
track_best_val_loss_step = track_best_val_loss_step.update( # pyrefly: ignore[missing-attribute]
val_metrics_cpu[config.early_stopping_metric], step
)
if config.early_stopping_metric in val_metrics_cpu:
_, early_stop = early_stop.update(
_, early_stop = early_stop.update( # pyrefly: ignore[missing-attribute]
val_metrics_cpu[config.early_stopping_metric], step
)
ran_validation = True
Expand Down