From 0e3b1fcef9be1ac1fcd7dc845806493fef8bee7e Mon Sep 17 00:00:00 2001 From: Aron Date: Wed, 18 Oct 2023 11:11:37 +0200 Subject: [PATCH] Change private attributes _total_epochs and _stopping_patience back to public as they are used during hyperoptimization --- n3fit/src/n3fit/stopping.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/n3fit/src/n3fit/stopping.py b/n3fit/src/n3fit/stopping.py index 0c9bc99e9a..e8cb972568 100644 --- a/n3fit/src/n3fit/stopping.py +++ b/n3fit/src/n3fit/stopping.py @@ -356,8 +356,8 @@ def __init__( self._dont_stop = dont_stop self._stop_now = False - self._stopping_patience = stopping_patience - self._total_epochs = total_epochs + self.stopping_patience = stopping_patience + self.total_epochs = total_epochs self._stop_epochs = [total_epochs - 1] * self._n_replicas self._best_epochs = [None] * self._n_replicas @@ -472,13 +472,13 @@ def monitor_chi2(self, training_info, epoch, print_stats=False): self._stopping_degrees[i_replica] = 0 self._counts[i_replica] = 1 - stop_replicas = self._counts & (self._stopping_degrees > self._stopping_patience) + stop_replicas = self._counts & (self._stopping_degrees > self.stopping_patience) for i_replica in np.where(stop_replicas)[0]: self._stop_epochs[i_replica] = epoch self._counts[i_replica] = 0 # By using the stopping degree we only stop when none of the replicas are improving anymore - if min(self._stopping_degrees) > self._stopping_patience: + if min(self._stopping_degrees) > self.stopping_patience: self.make_stop() return True @@ -501,7 +501,7 @@ def print_current_stats(self, epoch, fitstate): epoch_index = epoch + 1 tr_chi2 = fitstate.total_tr_chi2() vl_chi2 = fitstate.total_vl_chi2() - total_str = f"At epoch {epoch_index}/{self._total_epochs}, total chi2: {tr_chi2}\n" + total_str = f"At epoch {epoch_index}/{self.total_epochs}, total chi2: {tr_chi2}\n" # The partial chi2 makes no sense for more than one replica at once: if self._n_replicas == 1: