- layer: only calculate rms_error_accu() if status report is necessary
- Status: added wants_report
This commit is contained in:
+3
-1
@@ -69,8 +69,10 @@ class Layer:
|
|||||||
self.state.w_hv += inc_whv
|
self.state.w_hv += inc_whv
|
||||||
|
|
||||||
# Calculate error
|
# Calculate error
|
||||||
|
if status.want_report(round(training_seen*d_progress)):
|
||||||
err_rms = rms_error_accu(mini_batch - self.h_to_pv(self.v_to_ph(v_states)))
|
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": ""}}):
|
if not status.on_change({"progress": {"value": round(training_seen * d_progress), "unit": "%"},
|
||||||
|
"err_rms": {"value": err_rms, "unit": ""}}):
|
||||||
keep_running = False
|
keep_running = False
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ def cv_show(name: str, vec: np.array, shape):
|
|||||||
|
|
||||||
class MyStatus(Status):
|
class MyStatus(Status):
|
||||||
def __init__(self, _stack: StackDeep, _batch: np.ndarray):
|
def __init__(self, _stack: StackDeep, _batch: np.ndarray):
|
||||||
Status.__init__(self, update_interval=2)
|
Status.__init__(self, update_interval=10)
|
||||||
self.stack = _stack
|
self.stack = _stack
|
||||||
self.batch = _batch
|
self.batch = _batch
|
||||||
self.index = 0
|
self.index = 0
|
||||||
|
|||||||
+6
-8
@@ -15,17 +15,15 @@ class Status:
|
|||||||
print(f"{key} : {value}{unit}")
|
print(f"{key} : {value}{unit}")
|
||||||
|
|
||||||
def on_change(self, status: dict) -> bool:
|
def on_change(self, status: dict) -> bool:
|
||||||
do_continue = True
|
|
||||||
if status == {}:
|
|
||||||
self.progress = -1
|
|
||||||
|
|
||||||
if "progress" in status.keys():
|
|
||||||
progress = status["progress"]['value']
|
|
||||||
if self.progress < 0 or progress - self.progress >= self.update_interval:
|
|
||||||
self.progress = progress
|
|
||||||
do_continue = self.on_report(status=status)
|
do_continue = self.on_report(status=status)
|
||||||
|
|
||||||
return do_continue
|
return do_continue
|
||||||
|
|
||||||
|
def want_report(self, progress) -> bool:
|
||||||
|
if self.progress < 0 or progress - self.progress >= self.update_interval:
|
||||||
|
self.progress = progress
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def on_report(self, status: dict) -> bool:
|
def on_report(self, status: dict) -> bool:
|
||||||
return True
|
return True
|
||||||
Reference in New Issue
Block a user