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

Space between lines keeps increasing

Open ghost opened this issue 8 years ago • 10 comments

When I use the TQDM with Keras, it works well but each time an epoch is added, the space between the train loop progressbar and the epoch loop progressbar keeps increasing. It is anoying when I have several epoch. Here is an example:

image

ghost avatar Nov 16 '17 15:11 ghost

Same in my case. MacOS, Google Chrome.

I looked at the HTML code of the widget and discovered that every 'inner loop' leaves this code:

<div class="output_area">
    <div class="prompt"></div>
    <div class="output_subarea jupyter-widgets-view"></div>
</div>

So the code above repeats itself as many times as the number of the epochs. And this div's have nonzero height - that's why every inner loop adds blank spaces.

Maybe that is because the author of original TQDM changed something in the code.

dzubo avatar Dec 29 '17 02:12 dzubo

I think that's actually more a jupyter thing. What could fix this is if instead of generating a new tqdm for each epoch, it actually just re-uses the old one and manually sets n to zero.

(Of course, only when leave_inner = False)

janfreyberg avatar Feb 08 '18 11:02 janfreyberg

This is an issue with ipywidgets (#1845). The only fix so far is to revert to ipywidgets 6.0.1

phausamann avatar Mar 05 '18 13:03 phausamann

Here's an implementation of @janfreyberg 's suggestion https://github.com/bstriner/keras-tqdm/compare/master...starfys:master

Note: The tqdm.monitor_interval = 0 at the top is unrelated, but helps with a different issue I was having (https://github.com/tqdm/tqdm/issues/481)

Overall, this is a hack, and probably shouldn't be merged, but is useful in the meantime. The real issue is in ipywidgets (https://github.com/jupyter-widgets/ipywidgets/issues/1845)

starfys avatar Mar 06 '18 04:03 starfys

Fixed in ipywidgets 7.2.0

Update your ipywidgets package to the latest version if you have this problem.

phausamann avatar Apr 18 '18 14:04 phausamann

Just FYI I am still getting this with ipywidgets 7.2.1. I'd prefer to turn off the inner progress bar entirely, there a way to do that?

guillochon avatar Jul 05 '18 22:07 guillochon

Still getting this on ipywidgets 7.4.2, have there been any other fixes/workarounds?

alexisdrakopoulos avatar Nov 13 '18 19:11 alexisdrakopoulos

@alexisdrakopoulos > Still getting this on ipywidgets 7.4.2, have there been any other fixes/workarounds?

I found one!! https://github.com/jupyter-widgets/ipywidgets/issues/1845#issuecomment-422094518

You can use the following as a workaround:

from IPython.core.display import HTML
HTML("""
<style>
.p-Widget.jp-OutputPrompt.jp-OutputArea-prompt:empty {
  padding: 0;
  border: 0;
}
</style>
""")

TiagoCortinhal avatar Nov 29 '18 22:11 TiagoCortinhal

The workaround by @TiagoCortinhal worked for me. But I had to wrap it with the display function:

from keras_tqdm import TQDMNotebookCallback
display(HTML("""
    <style>
        .p-Widget.jp-OutputPrompt.jp-OutputArea-prompt:empty {
              padding: 0;
              border: 0;
        }
    </style>
"""))

marcosterland avatar Jan 24 '19 15:01 marcosterland

This is the only workaround that worked for me in JupyterLab:

from IPython.core.display import HTML

# See https://github.com/bstriner/keras-tqdm/issues/21#issuecomment-443019223
display(HTML("""
    <style>
        .jp-OutputArea-child:has(.jp-OutputArea-prompt:empty) {
              padding: 0 !important;
        }
    </style>
"""))

tommedema avatar Oct 18 '22 19:10 tommedema