Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tqdm_logger does not take epoch_length into account #782

Closed
remisphere opened this issue Feb 14, 2020 · 1 comment · Fixed by #785
Closed

tqdm_logger does not take epoch_length into account #782

remisphere opened this issue Feb 14, 2020 · 1 comment · Fixed by #785

Comments

@remisphere
Copy link

remisphere commented Feb 14, 2020

🐛 tqdm_logger does not take epoch_length into account

When calling Engine.run() with a custom epoch_length,
the tqdm progress bar does not adapt and displays the full number of batches in the data.
Here is a minimal example:

from ignite.contrib.handlers.tqdm_logger import ProgressBar
from ignite.engine import Engine
from torch import nn
from torch.utils.data import DataLoader

data = list(range(100))
model = nn.Identity()
engine = Engine(lambda engine, batch: model(batch))

ProgressBar(persist=True).attach(engine)
engine.run(data, epoch_length=50)

We have 100 items in data but the true end of the epoch is at 50 iterations, yet the progress is displayed over the range of 100 and just ends midway, when I expect it to be displayed over the range of 50, thus ending when the bar is full.
One can not overwrite tqdm's total argument by replacing

ProgressBar(persist=True).attach(engine)

by

ProgressBar(persist=True, total=50).attach(engine)

for it raises TypeError: type object got multiple values for keyword argument 'total'.

Environment

  • PyTorch Version : 1.4.0
  • Ignite Version : 0.3.0
  • OS : Ubuntu 19.04
  • Ignite installation method : pip
  • Python version: 3.7.3
@vfdev-5
Copy link
Collaborator

vfdev-5 commented Feb 14, 2020

@remisphere thanks for the feedback! We need to fix it here:

if event_name in (Events.ITERATION_STARTED, Events.ITERATION_COMPLETED):
return len(engine.state.dataloader)

as

if event_name in (Events.ITERATION_STARTED, Events.ITERATION_COMPLETED): 
    return engine.state.epoch_length

vfdev-5 pushed a commit that referenced this issue Feb 15, 2020
…785)

* fixes issue #782

* add test case for issue #782

* add test case for issue #782
@vfdev-5 vfdev-5 closed this as completed Feb 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants