fixed deep stack status update
This commit is contained in:
+3
-2
@@ -16,7 +16,7 @@ class Entity:
|
||||
if batch_size == 0:
|
||||
batch_size = training_remain
|
||||
|
||||
status.on_change({})
|
||||
status.on_change()
|
||||
d_progress = 100.0 / (training_remain/batch_size * self.params.num_epochs)
|
||||
batch_row_index = 0
|
||||
training_seen = 0
|
||||
@@ -49,8 +49,9 @@ class Entity:
|
||||
self.state.b_h += inc_bh
|
||||
self.state.w_hv += inc_whv
|
||||
|
||||
# Calculate error
|
||||
# check if status update is needed
|
||||
if status.want_report(round(training_seen*d_progress)):
|
||||
# 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": ""}}):
|
||||
|
||||
@@ -12,7 +12,7 @@ class StackDeep(Stack):
|
||||
for index, layer in enumerate(self.layers):
|
||||
if index == from_layer_id:
|
||||
break
|
||||
_batch = layer.v_to_ph(_batch)
|
||||
_batch = layer.entity.v_to_ph(_batch)
|
||||
|
||||
return _batch
|
||||
|
||||
@@ -21,19 +21,19 @@ class StackDeep(Stack):
|
||||
for index, layer in enumerate(self.layers):
|
||||
print(f"Train layer {index}")
|
||||
_batch = self.batch_from(batch, index)
|
||||
layer.train(_batch, cd_func=cd_jens, status=status)
|
||||
layer.entity.train(_batch, cd_func=cd_jens, status=status)
|
||||
|
||||
|
||||
def pass_up(self, visible: np.ndarray, from_layer_id: int = 0):
|
||||
h = np.matrix.copy(visible)
|
||||
for layer in self.layers[from_layer_id:]:
|
||||
h = layer.gibbs_v_to_h(h)
|
||||
h = layer.entity.gibbs_v_to_h(h)
|
||||
return h
|
||||
|
||||
def pass_down(self, hidden: np.ndarray, from_layer_id: int = 0):
|
||||
v = np.matrix.copy(hidden)
|
||||
for layer in list(reversed(self.layers))[from_layer_id:]:
|
||||
v = layer.gibbs_h_to_v(v)
|
||||
v = layer.entity.gibbs_h_to_v(v)
|
||||
return v
|
||||
|
||||
def pass_down_up(self, visible: np.ndarray, from_layer_id: int = 0):
|
||||
|
||||
+5
-2
@@ -14,9 +14,12 @@ class Status:
|
||||
else:
|
||||
print(f"{key} : {value}{unit}")
|
||||
|
||||
def on_change(self, status: dict) -> bool:
|
||||
do_continue = self.on_report(status=status)
|
||||
def on_change(self, status: dict|None=None) -> bool:
|
||||
if status is None:
|
||||
self.progress = -1
|
||||
return True
|
||||
|
||||
do_continue = self.on_report(status=status)
|
||||
return do_continue
|
||||
|
||||
def want_report(self, progress) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user