avalanche.training.ClassBalancedBuffer
- class avalanche.training.ClassBalancedBuffer(max_size: int, adaptive_size: bool = True, total_num_classes: int | None = None)[source]
Stores samples for replay, equally divided over classes.
There is a separate buffer updated by reservoir sampling for each class. It should be called in the ‘after_training_exp’ phase (see ExperienceBalancedStoragePolicy). The number of classes can be fixed up front or adaptive, based on the ‘adaptive_size’ attribute. When adaptive, the memory is equally divided over all the unique observed classes so far.
- __init__(max_size: int, adaptive_size: bool = True, total_num_classes: int | None = None)[source]
Init.
- Parameters:
max_size – The max capacity of the replay memory.
adaptive_size – True if mem_size is divided equally over all observed experiences (keys in replay_mem).
total_num_classes – If adaptive size is False, the fixed number of classes to divide capacity over.
Methods
__init__
(max_size[, adaptive_size, ...])Init.
get_group_lengths
(num_groups)Compute groups lengths given the number of groups num_groups.
post_adapt
(agent, exp)Update buffer.
resize
(strategy, new_size)Update the maximum size of the buffers.
update
(strategy, **kwargs)Update self.buffer using the strategy state.
update_from_dataset
(new_data[, strategy])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.