avalanche.benchmarks.utils.data_loader.ReplayDataLoader

class avalanche.benchmarks.utils.data_loader.ReplayDataLoader(data: avalanche.benchmarks.utils.avalanche_dataset.AvalancheDataset, memory: typing.Optional[avalanche.benchmarks.utils.avalanche_dataset.AvalancheDataset] = None, oversample_small_tasks: bool = False, collate_mbatches=<function _default_collate_mbatches_fn>, batch_size: int = 32, batch_size_mem: int = 32, task_balanced_dataloader: bool = False, **kwargs)[source]

Custom data loader for rehearsal/replay strategies.

__init__(data: avalanche.benchmarks.utils.avalanche_dataset.AvalancheDataset, memory: typing.Optional[avalanche.benchmarks.utils.avalanche_dataset.AvalancheDataset] = None, oversample_small_tasks: bool = False, collate_mbatches=<function _default_collate_mbatches_fn>, batch_size: int = 32, batch_size_mem: int = 32, task_balanced_dataloader: bool = False, **kwargs)[source]

Custom data loader for rehearsal strategies.

The iterates in parallel two datasets, the current data and the rehearsal memory, which are used to create mini-batches by concatenating their data together. Mini-batches from both of them are balanced using the task label (i.e. each mini-batch contains a balanced number of examples from all the tasks in the data and memory).

If oversample_small_tasks == True smaller tasks are oversampled to match the largest task.

Parameters
  • data – AvalancheDataset.

  • memory – AvalancheDataset.

  • oversample_small_tasks – whether smaller tasks should be oversampled to match the largest one.

  • collate_mbatches – function that given a sequence of mini-batches (one for each task) combines them into a single mini-batch. Used to combine the mini-batches obtained separately from each task.

  • batch_size – the size of the data batch. It must be greater than or equal to the number of tasks.

  • batch_size_mem – the size of the memory batch. If task_balanced_dataloader is set to True, it must be greater than or equal to the number of tasks.

  • task_balanced_dataloader – if true, buffer data loaders will be task-balanced, otherwise it creates a single data loader for the buffer samples.

  • kwargs – data loader arguments used to instantiate the loader for each task separately. See pytorch DataLoader.

Methods

__init__(data[, memory, ...])

Custom data loader for rehearsal strategies.