pantheonrl.algos.bc.EpochOrBatchIteratorWithProgress

class EpochOrBatchIteratorWithProgress(data_loader, n_epochs=None, n_batches=None, on_epoch_end=None, on_batch_end=None)[source]

Bases: object

Wraps DataLoader so that all BC batches can be processed in a one for-loop. Also uses tqdm to show progress in stdout. Args:

data_loader: An iterable over data dicts, as used in BC. n_epochs: The number of epochs to iterate through in one call to

__iter__. Exactly one of n_epochs and n_batches should be provided.

n_batches: The number of batches to iterate through in one call to

__iter__. Exactly one of n_epochs and n_batches should be provided.

on_epoch_end: A callback function without parameters to be called

at the end of every epoch.

on_batch_end: A callback function without parameters to be called

at the end of every batch.

Methods

set_data_loader

Set the data loader to new value

Parameters:
  • data_loader (Iterable[dict]) –

  • n_epochs (int | None) –

  • n_batches (int | None) –

  • on_epoch_end (Callable[[], None] | None) –

  • on_batch_end (Callable[[], None] | None) –

set_data_loader(new_data_loader)[source]

Set the data loader to new value