duo_ai.utils.wandb

Classes

WandbLogger

Simple logger for aggregating statistics and logging to Weights & Biases (wandb).

Module Contents

class duo_ai.utils.wandb.WandbLogger[source]

Simple logger for aggregating statistics and logging to Weights & Biases (wandb).

Examples

>>> logger = WandbLogger()
>>> logger.clear()
>>> logger['step'] = 1
>>> logger.add('train', {'loss': 0.1, 'acc': 0.9})
>>> stats = logger.get()
clear() None[source]

Clear the logger’s internal statistics dictionary.

Return type:

None

Examples

>>> logger = WandbLogger()
>>> logger.clear()
__setitem__(key: str, value: Any) None[source]

Set a statistic in the logger by key.

Parameters:
  • key (str) – The key for the statistic.

  • value (Any) – The value to store.

Return type:

None

Examples

>>> logger = WandbLogger()
>>> logger['step'] = 1
add(split: str, stats: Dict[str, Any]) None[source]

Add multiple statistics for a given split, prefixing keys with the split name.

Parameters:
  • split (str) – The split name (e.g., ‘train’, ‘test’).

  • stats (dict) – Dictionary of statistics to add.

Return type:

None

Examples

>>> logger = WandbLogger()
>>> logger.add('train', {'loss': 0.1, 'acc': 0.9})
get() Dict[str, Any][source]

Retrieve the current statistics dictionary.

Returns:

The current statistics log.

Return type:

dict

Examples

>>> logger = WandbLogger()
>>> logger.clear()
>>> logger['step'] = 1
>>> logger.add('train', {'loss': 0.1, 'acc': 0.9})
>>> stats = logger.get()