revised status
This commit is contained in:
+7
-11
@@ -34,8 +34,8 @@ class Layer:
|
|||||||
if batch_size == 0:
|
if batch_size == 0:
|
||||||
batch_size = training_remain
|
batch_size = training_remain
|
||||||
|
|
||||||
|
status.on_change({})
|
||||||
d_progress = 100.0 / (training_remain/batch_size * self.params.num_epochs)
|
d_progress = 100.0 / (training_remain/batch_size * self.params.num_epochs)
|
||||||
last_progress = 0
|
|
||||||
batch_row_index = 0
|
batch_row_index = 0
|
||||||
training_seen = 0
|
training_seen = 0
|
||||||
keep_running = True
|
keep_running = True
|
||||||
@@ -67,19 +67,15 @@ class Layer:
|
|||||||
self.state.b_h += inc_bh
|
self.state.b_h += inc_bh
|
||||||
self.state.w_hv += inc_whv
|
self.state.w_hv += inc_whv
|
||||||
|
|
||||||
progress = round(training_seen*d_progress)
|
# Calculate error
|
||||||
if progress != last_progress:
|
err_rms = rms_error_accu(mini_batch - self.h_to_pv(self.v_to_ph(v_states)))
|
||||||
# Calculate error
|
if not status.on_change({"progress": {"value": round(training_seen*d_progress), "unit": "%"}, "err_rms": {"value": err_rms, "unit": ""}}):
|
||||||
status.progress = round(progress)
|
keep_running = False
|
||||||
status.err = rms_error_accu(mini_batch - self.h_to_pv(self.v_to_ph(v_states)))
|
break
|
||||||
if not status.on_change():
|
|
||||||
keep_running = False
|
|
||||||
break
|
|
||||||
|
|
||||||
last_progress = progress
|
|
||||||
training_seen += 1
|
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:
|
def v_to_ph(self, v: np.ndarray) -> np.ndarray:
|
||||||
state = self.state.v_to_h(v)
|
state = self.state.v_to_h(v)
|
||||||
|
|||||||
+14
-12
@@ -1,16 +1,18 @@
|
|||||||
class Status:
|
class Status:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.progress = 0
|
self.progress = -1
|
||||||
self.err = -1.0
|
|
||||||
self.err_total = -1.0
|
|
||||||
self.l1 = -1.0
|
|
||||||
self.l2 = -1.0
|
|
||||||
|
|
||||||
def on_change(self) -> bool:
|
def on_change(self, status: dict) -> bool:
|
||||||
print("-------------------------------------------")
|
if status == {}:
|
||||||
print(f"Progress : {self.progress} %")
|
self.progress = -1
|
||||||
print(f"error (per mini batch) : {self.err}")
|
|
||||||
print(f"error (total) : {self.err_total}")
|
if "progress" in status.keys():
|
||||||
print(f"L1 : {self.l1}")
|
progress = status["progress"]['value']
|
||||||
print(f"L2 : {self.l2}")
|
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
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user