bstriner / keras-tqdm

Keras integration with TQDM progress bars
MIT License
348 stars 41 forks source link

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

Open zaccharieramzi opened 4 years ago

zaccharieramzi commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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.

shun-lin commented 4 years ago

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!

jtlz2 commented 4 years ago

@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?