revised status

This commit is contained in:
2025-12-17 13:15:09 +01:00
parent 99657265af
commit 575ceb4ef1
2 changed files with 21 additions and 23 deletions
+7 -11
View File
@@ -34,8 +34,8 @@ class Layer:
if batch_size == 0:
batch_size = training_remain
status.on_change({})
d_progress = 100.0 / (training_remain/batch_size * self.params.num_epochs)
last_progress = 0
batch_row_index = 0
training_seen = 0
keep_running = True
@@ -67,19 +67,15 @@ class Layer:
self.state.b_h += inc_bh
self.state.w_hv += inc_whv
progress = round(training_seen*d_progress)
if progress != last_progress:
# Calculate error
status.progress = round(progress)
status.err = rms_error_accu(mini_batch - self.h_to_pv(self.v_to_ph(v_states)))
if not status.on_change():
keep_running = False
break
# Calculate error
err_rms = rms_error_accu(mini_batch - self.h_to_pv(self.v_to_ph(v_states)))
if not status.on_change({"progress": {"value": round(training_seen*d_progress), "unit": "%"}, "err_rms": {"value": err_rms, "unit": ""}}):
keep_running = False
break
last_progress = progress
training_seen += 1
status.on_change()
status.on_change({"progress": {"value": round(training_seen*d_progress), "unit": "%"}, "err_rms": {"value": err_rms, "unit": ""}})
def v_to_ph(self, v: np.ndarray) -> np.ndarray:
state = self.state.v_to_h(v)
+14 -12
View File
@@ -1,16 +1,18 @@
class Status:
def __init__(self):
self.progress = 0
self.err = -1.0
self.err_total = -1.0
self.l1 = -1.0
self.l2 = -1.0
self.progress = -1
def on_change(self) -> bool:
print("-------------------------------------------")
print(f"Progress : {self.progress} %")
print(f"error (per mini batch) : {self.err}")
print(f"error (total) : {self.err_total}")
print(f"L1 : {self.l1}")
print(f"L2 : {self.l2}")
def on_change(self, status: dict) -> bool:
if status == {}:
self.progress = -1
if "progress" in status.keys():
progress = status["progress"]['value']
if self.progress < 0 or progress - self.progress >= 10:
self.progress = progress
print("-------------------------------------------")
for key in status.keys():
value = status[key]['value']
unit = status[key]['unit']
print(f"{key} : {value}{unit}")
return True