avalanche.training.BalancedExemplarsBuffer

class avalanche.training.BalancedExemplarsBuffer(max_size: int, adaptive_size: bool = True, total_num_groups=None)[source]

A buffer that stores exemplars for rehearsal in separate groups.

The grouping allows to balance the data (by task, experience, classes..). In combination with balanced data loaders, it can be used to sample balanced mini-batches during training.

self.buffer_groups is a dictionary that stores each group as a separate buffer. The buffers are updated by calling self.update(strategy).

__init__(max_size: int, adaptive_size: bool = True, total_num_groups=None)[source]
Parameters:
  • max_size – max number of input samples in the replay memory.

  • adaptive_size – True if max_size is divided equally over all observed experiences (keys in replay_mem).

  • total_num_groups – If adaptive size is False, the fixed number of groups to divide capacity over.

Methods

__init__(max_size[, adaptive_size, ...])

param max_size:

max number of input samples in the replay memory.

get_group_lengths(num_groups)

Compute groups lengths given the number of groups num_groups.

post_adapt(agent_state, exp)

Update self.buffer using the agent state and current experience.

resize(strategy, new_size)

Update the maximum size of the buffers.

update(strategy, **kwargs)

Update self.buffer using the strategy state.

Attributes

buffer

Buffer of samples.

buffer_datasets

Return group buffers as a list of `AvalancheDataset`s.

buffer_groups

Dictionary of buffers.

max_size

Maximum size of the buffer.