tensorflow / addons

Useful extra functionality for TensorFlow 2.x maintained by SIG-addons
Apache License 2.0
1.69k stars 612 forks source link

Have TQDMProgressBar work in evaluate mode as well #1620

Closed zaccharieramzi closed 4 years ago

zaccharieramzi commented 4 years ago

Describe the feature and the current behavior/state.

Right now, the TQDMProgressBar callback can only be used when training a model. When evaluating nothing happens. And even if I try to "cheat" by manually setting the on_test_batch_(begin|end) methods, it fails with an error about mode.

Relevant information

Which API type would this fall under (layer, metric, optimizer, etc.) callbacks

Who will benefit with this feature? everyone using tqdm to evaluate in a notebook: I want something fancier than the default evaluate progressbar

Any other info. It failed in both tf2.2 and tf2.1

You can find the colab gist here.

gabrieldemarmiesse commented 4 years ago

I don't think it would be hard to do because keras exposes methods for that: e.g. https://www.tensorflow.org/api_docs/python/tf/keras/callbacks/Callback#on_test_batch_begin . Contributions welcome!

ashutosh1919 commented 4 years ago

@gabrieldemarmiesse , please review PR #38447

gabrieldemarmiesse commented 4 years ago

As a small note, I believe the TQDM callback should have a cleanup as we removed the "samples" mode and a refactoring would be welcome before a PR to add this feature. There is definitly some dead code/renaming to do.

ashutosh1919 commented 4 years ago

Yep. Got it. Let me do that too.

ashutosh1919 commented 4 years ago

@gabrieldemarmiesse , I have created PR for adding methods on_test_batch_begin() and on_test_batch_end(). I have also looked at removing unused code related to samples mode. I have found one clue here. But since, I am not aware about past implementation and changes, I couldn't do on my own. Please give me hints or point me the direction where I can find one.

shun-lin commented 4 years ago

ops, sorry I have forgot about evaluate() when I wrote it and thanks @ashutosh1919 so much for the contribution!

ashutosh1919 commented 4 years ago

@zaccharieramzi and @gabrieldemarmiesse , please review PR. Creates as below. tqdm_pbar_demo - Colaboratory