keras-tqdm icon indicating copy to clipboard operation
keras-tqdm copied to clipboard

The update of the progress bar is not correct for tensorflow 2

Open zaccharieramzi opened this issue 5 years ago • 4 comments

The progress bar is update with the batch size instead of 1.

This is due to the mode being 0, when it should be 1. The mode is set here: https://github.com/bstriner/keras-tqdm/blob/master/keras_tqdm/tqdm_callback.py#L85-L92 but this technique doesn't work for tensorflow 2, where the params might look like this:

{'batch_size': None, 'epochs': 200, 'steps': 90, 'samples': 90, 'verbose': 2, 'do_validation': True, 'metrics': ['loss',]}

I will provide a minimal example to highlight this and make a PR if this repo is still maintained (which it doesn't look like @bstriner ?).

zaccharieramzi avatar Nov 19 '19 14:11 zaccharieramzi

This actually comes from the fact, that in tf 2, the number of samples is computed like the following: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/keras/engine/training_generator.py#L165-L176 , so the number of samples in the callbacks might actually just be the number of steps...

zaccharieramzi avatar Nov 19 '19 15:11 zaccharieramzi

That is why for their progress bar they use count_mode, rather than anything else. I don't see how we could cope with that, if we don't have access to this variable.

zaccharieramzi avatar Nov 19 '19 15:11 zaccharieramzi

Hi,

I have made a tqdm progress bar for tensorflow and add it to Tensorflow Addons (tfa), you can see the tutorial here: https://github.com/tensorflow/addons/blob/master/docs/tutorials/tqdm_progress_bar.ipynb

and the source code here: https://github.com/tensorflow/addons/blob/master/tensorflow_addons/callbacks/tqdm_progress_bar.py

if this problem persists in the code linked above please open an issue in tf addons and I will address it, thank you!

shun-lin avatar Nov 20 '19 05:11 shun-lin

@shun-lin Thank you! Unfortunately when running inside jupyter notebook there is one progress bar for training but also one progress bar per epoch (of which there are many in my case), if that makes sense. This leads to a long list of green progress bars. Please advise?

jtlz2 avatar May 27 '20 12:05 jtlz2