From 3a87063577586c3b0f9f006ea2be2cecaf14006d Mon Sep 17 00:00:00 2001 From: Melvin Wong Date: Tue, 9 Jul 2024 10:36:17 +0200 Subject: [PATCH] fix: added optimal acceptance time recording to results --- pycmtensor/results.py | 2 ++ pycmtensor/run.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/pycmtensor/results.py b/pycmtensor/results.py index 1297915..46c8792 100644 --- a/pycmtensor/results.py +++ b/pycmtensor/results.py @@ -46,6 +46,7 @@ def __init__(self): """ self.build_time = None self.train_time = None + self.accept_time = None self.epochs_per_sec = None self.n_params = None self.n_train = None @@ -145,6 +146,7 @@ def benchmark(self): stats.loc["Seed"] = self.config.seed stats.loc["Model build time"] = self.build_time stats.loc["Model train time"] = self.train_time + stats.loc["Optimal train time"] = self.accept_time stats.loc["epochs per sec"] = f"{self.epochs_per_sec} epoch/s" return stats diff --git a/pycmtensor/run.py b/pycmtensor/run.py index a835885..0aeea13 100644 --- a/pycmtensor/run.py +++ b/pycmtensor/run.py @@ -284,6 +284,10 @@ def accept_condition(model, i, ll, error): max_patience = max(model.patience, i * model.config.patience_increase) model.patience = int(min(max_patience, model.config.max_iterations)) + now = perf_counter() + accept_time = round(now - model.results.start_time, 3) + model.results.accept_time = time_format(accept_time) + return accept