How to display training progress bar in tensorflow?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
TensorFlow can show training progress in several different ways, and the best choice depends on whether you are using model.fit() or a custom training loop. Many projects overcomplicate this by reaching for third-party progress bars before checking what Keras already provides. In practice, the simplest reliable solution is usually the built-in progress display, with callbacks or manual bars only when you need extra control.
Use Keras Built-In Progress First
If training happens through model.fit(), start with Keras verbosity settings:
verbose=1 gives the standard progress bar. verbose=2 prints one line per epoch and is often better for CI logs or remote terminals.
For many teams, this is enough. Replace it only when you need custom metrics or tighter control over display behavior.
Use a Callback for Extra Information
If you want more than the default progress bar, callbacks are the clean extension point.
This is useful when you need to show learning rate, ETA, custom counters, or push metrics into another system without rewriting training.
Use Progbar in a Custom Loop
Once you move to a manual GradientTape loop, the Keras progress bar is gone. At that point, tf.keras.utils.Progbar is a good built-in replacement.
Progbar keeps you inside the TensorFlow ecosystem and avoids another dependency. It works well when you want one clear terminal progress line per epoch.
Use tqdm When You Want Richer Control
If you need nested bars, notebook-friendly rendering, or a more customizable loop display, tqdm is a good choice.
The main advantage of tqdm is presentation flexibility. The main drawback is that it is easier to produce messy output if the loop structure is not clean.
Which Option Should You Choose?
Use this rule of thumb:
- '
model.fit(..., verbose=1)for ordinary Keras training' - callbacks when you want extra information during
fit - '
Progbarfor a simple custom TensorFlow loop' - '
tqdmwhen you want richer terminal or notebook UX'
The right answer depends more on the training API than on TensorFlow itself.
Common Pitfalls
- Updating a Python progress bar inside
@tf.function. Fix: keep progress updates outside graph-compiled functions. - Printing every batch for long training jobs. Fix: prefer aggregated progress unless you are actively debugging.
- Materializing the whole dataset just to count steps. Fix: compute step count from dataset metadata or source size when possible.
- Using terminal-only progress bars in notebooks. Fix: use
tqdm.autoor a notebook-aware display mode. - Replacing
model.fit()progress too early. Fix: start with Keras built-ins before building custom UI logic.
Summary
- For
model.fit(), the built-in Keras progress bar is usually enough. - Use callbacks when you want custom status information without rewriting training.
- Use
tf.keras.utils.Progbarfor simple custom loops. - Use
tqdmwhen presentation control matters more than keeping dependencies minimal. - Keep progress updates outside
@tf.functionand avoid overly chatty per-batch printing in large jobs.

