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, force_data_batch_size: typing.Optional[int] = None, **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, force_data_batch_size: typing.Optional[int] = None, **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 batch. It must be greater than or equal to the number of tasks.

  • ratio_data_mem – How many of the samples should be from

  • 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.