Skip to content
heliaEDGE
Reference
HELIA

tqdm_progress_bar

Machine-readable model

class

helia_edge/callbacks/tqdm_progress_bar.py:15

TQDMProgressBar(
metrics_separator: str = ' - ',
overall_bar_format: str = '{l_bar}{bar} {n_fmt}/{total_fmt} ETA: {remaining}s, {rate_fmt}{postfix}',
epoch_bar_format: str = '{n_fmt}/{total_fmt}{bar} ETA: {remaining}s - {desc}',
metrics_format: str = '{name}: {value:0.4f}',
update_per_second: int = 10,
leave_epoch_progress: bool = True,
leave_overall_progress: bool = True,
show_epoch_progress: bool = True,
show_overall_progress: bool = True,
)

TQDM Progress Bar callback.

Example:

import time
import helia_edge as helia
# Create a TQDM progress bar
pb_callback = helia.callbacks.TQDMProgressBar(
overall_bar_format="{l_bar}{bar} {n_fmt}/{total_fmt}, {rate_fmt}{postfix}",
epoch_bar_format="{n_fmt}/{total_fmt}{bar} - {desc}",
metrics_format="{name}: {value:0.4f}",
update_per_second=10,
leave_epoch_progress=True,
)
# Simulate training
epochs = 10
steps = 5
pb_callback.set_params(dict(epochs=epochs, steps=steps))
pb_callback.on_train_begin()
loss = 1.0
accuracy = 0.0
for epoch in range(epochs):
pb_callback.on_epoch_begin(epoch)
for step in range(steps):
loss -= epoch * step / (epochs * steps)
accuracy += epoch * step / (epochs * steps)
pb_callback.on_batch_end(step, {"loss": loss, "accuracy": accuracy})
time.sleep(0.1)
pb_callback.on_epoch_end(epoch, {"loss": loss, "accuracy": accuracy})
pb_callback.on_train_end()
Parameters of TQDMProgressBar
NameTypeDefaultDescription
metrics_separatorstr' - 'Custom separator between metrics. Defaults to ' - '.
overall_bar_formatstr'{l_bar}{bar} {n_fmt}/{total_fmt} ETA: {remaining}s, {rate_fmt}{postfix}'Custom bar format for overall (outer) progress bar, see https://github.com/tqdm/tqdm#parameters for more detail.
epoch_bar_formatstr'{n_fmt}/{total_fmt}{bar} ETA: {remaining}s - {desc}'Custom bar format for epoch (inner) progress bar, see https://github.com/tqdm/tqdm#parameters for more detail.
update_per_secondint10Maximum number of updates in the epochs bar per second, this is to prevent small batches from slowing down training. Defaults to 10.
metrics_formatstr'{name}: {value:0.4f}'Custom format for how metrics are formatted. See https://github.com/tqdm/tqdm#parameters for more detail.
leave_epoch_progressboolTrue`True` to leave epoch progress bars.
leave_overall_progressboolTrue`True` to leave overall progress bar.
show_epoch_progressboolTrue`False` to hide epoch progress bars.
show_overall_progressboolTrue`False` to hide overall progress bar.
method

Format metrics in logs into a string.

helia_edge/callbacks/tqdm_progress_bar.py:222

format_metrics(logs: dict = {}, factor=1) -> str

Format metrics in logs into a string.

Parameters of format_metrics
NameTypeDefaultDescription
logsdict{}dictionary of metrics and their values. Defaults to empty dictionary.
factorint1The factor we want to divide the metrics in logs by, useful when we are computing the logs after each batch. Defaults to 1.
Returns of format_metrics
ValueTypeDescription
metrics_stringstra string displaying metrics using the given
strformators passed in through the constructor.