From 9ac3d893f293b1dcf0f7d2fc9bac0addeaf5214c Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Thu, 12 Apr 2018 01:02:30 +0100 Subject: [PATCH] tidy tqdm - Uses latest `postfix` versatility of `tqdm>=4.22.0` - pin tqdm>=4.22.0 --- main_loop_tf/main.py | 19 +++++++++++-------- setup.py | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/main_loop_tf/main.py b/main_loop_tf/main.py index e5c5b30..1da1bbf 100644 --- a/main_loop_tf/main.py +++ b/main_loop_tf/main.py @@ -940,12 +940,15 @@ def epoch_begin(self): simple_value=self.epoch_id + 1) summary = tf.Summary(value=[summary_val]) self.summary_writer.add_summary(summary, self.epoch_id) - bar_format = '{n_fmt}/{total_fmt}{desc}{percentage:3.0f}%|{bar}| ' - bar_format += '[{elapsed}<{remaining},{rate_fmt}{postfix}]' + bar_format = ( + '{n_fmt}/{total_fmt}({postfix[step]:3d}) Ep {postfix[epoch]:d}:' + ' {percentage:3.0f}%|{bar}| [{elapsed}<{remaining},{rate_fmt},' + ' D={postfix[D]:.2f}s, loss={postfix[loss]:.3f}]') self.pbar = tqdm(total=self.train.nbatches, initial=self.global_step_val % self.train.nbatches, dynamic_ncols=True, - bar_format=bar_format) + bar_format=bar_format, + postfix=dict(step=0, epoch=0, D=0, loss=0)) def batch_begin(self): iter_start = time() @@ -1026,11 +1029,11 @@ def batch_do(self): self.loss_value = fetch_dict['avg_loss'] def batch_end(self): - self.pbar.set_description('({:3d}) Ep {:d}'.format( - self.global_step_val + 1, self.epoch_id + 1)) - avg_loss = self._fetch_dict['avg_loss'] - self.pbar.set_postfix({'D': '{:.2f}s'.format(self._t_data_load), - 'loss': '{:.3f}'.format(avg_loss)}) + self.pbar.postfix.update( + step=self.global_step_val + 1, + epoch=self.epoch_id + 1, + D=self._t_data_load, + loss=self._fetch_dict['avg_loss']) self.pbar.update(1) self.global_step_val += 1 diff --git a/setup.py b/setup.py index 14c6d5c..a7df32f 100644 --- a/setup.py +++ b/setup.py @@ -81,7 +81,7 @@ # your project is installed. For an analysis of "install_requires" vs pip's # requirements files see: # https://packaging.python.org/en/latest/requirements.html - install_requires=['numpy', 'tensorflow', 'tqdm', 'python-gflags'], + install_requires=['numpy', 'tensorflow', 'tqdm>=4.22.0', 'python-gflags'], # List additional groups of dependencies here (e.g. development # dependencies). You can install these using the following syntax,