Skip to content

Commit

Permalink
tidy tqdm
Browse files Browse the repository at this point in the history
- Uses latest `postfix` versatility of `tqdm>=4.22.0`
- pin tqdm>=4.22.0
  • Loading branch information
casperdcl committed Apr 12, 2018
1 parent db4abf5 commit 9ac3d89
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
19 changes: 11 additions & 8 deletions main_loop_tf/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 9ac3d89

Please sign in to comment.