drytorch.trackers.tqdm

Module containing a tqdm tracker for progress bars.

Classes

EpochBar(batch_size, n_iter, n_samples, ...)

Bar that displays the current epoch's metrics and progress.

TqdmLogger(leave, enable_training_bar, file)

Create an epoch progress bar.

TrainingBar(start_epoch, end_epoch, file, leave)

Create a bar for the training progress.

class EpochBar(batch_size: int | None, n_iter: int, n_samples: int, leave: bool, file: SupportsWrite[str], desc: str, position: int = 0)[source]

Bases: object

Bar that displays the current epoch’s metrics and progress.

This class is also used to display metrics and progress during evaluation.

fmt

the formatting of the bar.

Type:

ClassVar[str]

seen_str

the name for the elements of the batches.

Type:

ClassVar[str]

color

the color of the bar.

Type:

ClassVar[str]

pbar

the wrapped tqdm bar.

Type:

tqdm.asyncio.tqdm_asyncio

Initialize.

Parameters:
  • batch_size (int | None) – how many samples are in one batch.

  • n_iter (int) – the number of expected iterations.

  • n_samples (int) – the total number of samples.

  • leave (bool) – whether to leave the bar in after the epoch.

  • file (SupportsWrite[str]) – the stream where to flush the bar.

  • desc (str) – description to contextualize the bar.

  • position (int) – position of the bar in the progress bar group.

update(metrics: Mapping[str, Any], n_processes: int) None[source]

Update the bar and displays last batch metrics values.

Parameters:
  • metrics (Mapping[str, Any]) – the values from the last batch by metric name.

  • n_processes (int) – the number of processes used for data loading.

Return type:

None

class TqdmLogger(leave: bool = True, enable_training_bar: bool = False, file: SupportsWrite[str] = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>)[source]

Bases: Tracker

Create an epoch progress bar.

Initialize.

Parameters:
  • leave (bool) – whether to leave the epoch bar after completion.

  • enable_training_bar (bool) – create a bar for the overall training progress.

  • file (SupportsWrite[str]) – the stream where to flush the bar.

Note

Enable the training bar only if two progress bars are supported, and there is no other logger or printer streaming.

clean_up() None[source]

Override to clean up the tracker.

Return type:

None

notify(event: Event) None[source]
notify(event: IterateBatchEvent) None
notify(event: StartTrainingEvent) None
notify(event: StartEpochEvent) None
notify(event: EndEpochEvent) None
notify(event: EndTestEvent) None
notify(event: TerminatedTrainingEvent) None
notify(event: EndTrainingEvent) None

Notify the tracker of an event.

Parameters:

event (Event) – the event to notify about.

Return type:

None

class TrainingBar(start_epoch: int, end_epoch: int, file: SupportsWrite[str], leave: bool)[source]

Bases: object

Create a bar for the training progress.

Class Attributes:

fmt: the formatting of the bar. desc: the name for the iteration. color: the color of the bar.

pbar

the wrapped tqdm bar.

Type:

tqdm.asyncio.tqdm_asyncio

Initialize.

Parameters:
  • start_epoch (int) – the epoch from which the bar should start.

  • end_epoch (int) – the epoch where the bar should end.

  • file (SupportsWrite[str]) – the stream where to flush the bar.

  • leave (bool) – If True, leave the bar once the iterations have completed.

update(current_epoch: int) None[source]

Update the bar and display the current epoch.

Parameters:

current_epoch (int) – the current epoch.

Return type:

None