Skip to content

Commit

Permalink
Better progress printing
Browse files Browse the repository at this point in the history
  • Loading branch information
csxeba committed Mar 4, 2020
1 parent c1a2ef3 commit effd766
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions brainforge/learner/abstract_learner.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def epoch(self, generator, updates_per_epoch, metrics=(), validation=None, valid
epoch_metrics = self.learn_batch(*batch, metrics=metrics, **kw)
history.record(epoch_metrics)
if verbose:
history.log(prefix="\r", end="")
history.log(prefix="\rTraining ", end="", add_progress=True)

self.layers.learning = False
if verbose and validation:
Expand All @@ -77,7 +77,7 @@ def epoch(self, generator, updates_per_epoch, metrics=(), validation=None, valid
if validation_steps is None:
raise RuntimeError("If validating on a stream, validation_steps must be set to a positive integer.")
eval_history = self.evaluate_stream(validation, validation_steps, metrics, verbose=False)
eval_history.log(prefix=" ", suffix="")
eval_history.log(prefix=" Validation ", suffix="", add_progress=False)

if verbose:
print(f" took {time.time() - start // 60} minutes")
Expand Down
4 changes: 2 additions & 2 deletions brainforge/util/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def update(self, data: "MetricLogs"):
def __getitem__(self, item):
return self._metrics[item]

def log(self, prefix="", suffix="", **print_kwargs):
def log(self, prefix="", suffix="", add_progress=True, **print_kwargs):
log_str = []
if self._max_steps > 0:
if self._max_steps > 0 and add_progress:
log_str.append("Progress: {:>6.1%} ".format(self._step / self._max_steps))
means = self.mean()
log_str += ["{}: {:.4f}".format(metric, metric_values) for metric, metric_values in means.items()]
Expand Down

0 comments on commit effd766

Please sign in to comment.