SimpleProgressBar#
- class braintools.trainer.SimpleProgressBar(width=50, refresh_rate=0.1)#
Simple text-based progress bar with no dependencies.
Provides a basic progress bar that works in any terminal.
- Parameters:
Examples
The bar redraws itself in place with
\r; here the output is captured and only the final frame is shown:>>> import contextlib, io >>> import braintools >>> buf = io.StringIO() >>> with contextlib.redirect_stdout(buf): ... pbar = braintools.trainer.SimpleProgressBar(width=10) ... pbar.start(total=4, desc='Training') ... for _ in range(4): ... pbar.update(1) ... pbar.set_postfix({'loss': 0.25}) ... pbar.close() >>> print(buf.getvalue().split('\r')[-1].strip()) Training: 100.0%|=========>| 4/4 [...] loss=0.2500