fixed progress indication
This commit is contained in:
+6
-6
@@ -11,15 +11,15 @@ class Entity:
|
||||
self.params = params
|
||||
|
||||
def train(self, batch: np.ndarray, cd_func: Callable, status: Status):
|
||||
training_remain = batch.shape[0]
|
||||
training_remain = batch.shape[1]
|
||||
batch_size = min(self.params.mini_batch_size, training_remain)
|
||||
if batch_size == 0:
|
||||
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*self.params.num_epochs)
|
||||
progress = 0
|
||||
batch_row_index = 0
|
||||
training_seen = 0
|
||||
keep_running = True
|
||||
while training_remain > 0 and keep_running:
|
||||
batch_size_remain = min(batch_size, training_remain)
|
||||
@@ -50,15 +50,15 @@ class Entity:
|
||||
self.state.w_hv += inc_whv
|
||||
|
||||
# check if status update is needed
|
||||
if status.want_report(round(training_seen*d_progress)):
|
||||
if status.want_report(round(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": "%"},
|
||||
if not status.on_change({"progress": {"value": round(progress), "unit": "%"},
|
||||
"err_rms": {"value": err_rms, "unit": ""}}):
|
||||
keep_running = False
|
||||
break
|
||||
|
||||
training_seen += 1
|
||||
progress += d_progress*batch_size_remain
|
||||
|
||||
def v_to_ph(self, v: np.ndarray) -> np.ndarray:
|
||||
state = self.state.v_to_h(v)
|
||||
|
||||
Reference in New Issue
Block a user