Add optional show_epoch flag to ProgressBar for customizable epoch display#3628
Add optional show_epoch flag to ProgressBar for customizable epoch display#3628SpandanBhoiIITM wants to merge 1 commit intopytorch:masterfrom
show_epoch flag to ProgressBar for customizable epoch display#3628Conversation
|
@SpandanBhoiIITM Thanks for the contribution.
|
|
@SpandanBhoiIITM @TahaZahid05 I suggest to discuss the problem before reviewing the code change. We should not introduce alternative API if already exists a solution to the problem. |
|
@vfdev-5. However, doing this is flawed because it breaks the progress bar's ability to have a title. If a user removes the @SpandanBhoiIITM Given this, rather than introducing a strict For instance, Users can pass What do you think? |
@SpandanBhoiIITM can provide a small reproducer of what you are trying to achieve to see explicitly what does not work as desired. Thanks! For example, this code: from ignite.engine import Engine, Events
from ignite.handlers import ProgressBar
train_data = range(100)
eval_data = range(40)
max_epochs = 10
def train_step(engine, batch):
import time
time.sleep(0.01)
return None
trainer = Engine(train_step)
evaluator = Engine(lambda e, b: None)
@trainer.on(Events.EPOCH_COMPLETED(every=2))
def run_validation():
evaluator.run(eval_data)
ProgressBar(persist=True, desc="Training").attach(trainer)
ProgressBar(persist=True, desc="Validation").attach(evaluator)
trainer.run(train_data, max_epochs=max_epochs)gives the following representation in Jupyter notebook and if we are bothered that progress bars are not aligned we can redefine the bar format as we would like: bformat = "{percentage:3.0f}%|{bar}{postfix} [{elapsed}<{remaining}] - {desc}[{n_fmt}/{total_fmt}]"
ProgressBar(persist=True, bar_format=bformat, desc="Training").attach(trainer)
ProgressBar(persist=True, bar_format=bformat, desc="Validation").attach(evaluator)
|
|
@vfdev-5 @TahaZahid05 Thanks for the feedback! My motivation for adding Right now the only way to remove the epoch is by rewriting the whole The I, however agree that a |
|
@SpandanBhoiIITM First, can you kindly reproduce some code examples of progress bar formats that currently do not work as desired? This would help us in understanding where the current implementation is lacking. You can refer to the conversation above for more guidance. |
|
I ran a small example to illustrate the current behavior and the motivation behind this change. from ignite.engine import Engine, Events
from ignite.handlers import ProgressBar
train_data = range(100)
eval_data = range(40)
max_epochs = 4
def train_step(engine, batch):
import time
time.sleep(0.01)
trainer = Engine(train_step)
evaluator = Engine(lambda e, b: None)
@trainer.on(Events.EPOCH_COMPLETED(every=2))
def run_validation():
evaluator.run(eval_data)
ProgressBar(persist=True, desc="Training").attach(trainer)
ProgressBar(persist=True, desc="Validation").attach(evaluator)
trainer.run(train_data, max_epochs=max_epochs)Current behaviorThis produces the following representation in the terminal / Jupyter notebook:
Here the epoch information Attempt using
|
|
@SpandanBhoiIITM what's the point to remove the appended epoch/max-epochs info ? To move forward with this, I suggest to create an issue discussing this feature. If there's a support of the community on it, we can consider this PR. For now, personally I do not see the usefulness of this feature. |





Closes #3659
Description
This PR adds a
show_epochparameter toignite.handlers.tqdm_logger.ProgressBar.Currently, epoch information (e.g. "[5/10]") is automatically appended to the
progress bar description when
max_epochs > 1. This behavior makes itdifficult to align multiple progress bars (e.g. trainer and evaluator) with
custom formatting.
The new
show_epochflag (default=True) allows users to disable automaticepoch display while preserving backward compatibility.
All existing behavior remains unchanged by default.
Checklist