memory
MemoryMechanism
Implements the memory handling/manipulation for continual learning algorithms.
Source code in sequel/benchmarks/memory.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|
pack_bins_uniformly(num_samples, num_categories)
staticmethod
Splits an integer to a specified number of bins so that bins have approximately the same size. If
num_categories
is not a divisor of num_samples
, the reminder is split an equal number of bins selectrd
uniformly at random.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num_samples |
int
|
The number of items. |
required |
num_categories |
int
|
the number of bins. |
required |
Returns:
Type | Description |
---|---|
List[int]
|
List[int]: a list containing the number of items corresponding to each bin. |
Source code in sequel/benchmarks/memory.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|
sample_uniform_class_indices(dataset, num_samples)
staticmethod
Selects an approximately equal (ties broken arbitrarily) number of indices corresponding to each class from the input dataset. Each dataset yields ~num_samples // num_classes samples.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset |
ContinualDataset
|
The dataset that is sampled. |
required |
num_samples |
int
|
the number of samples to draw. |
required |
Returns:
Type | Description |
---|---|
List[int]
|
List[int]: The selected dataset indices. |
Source code in sequel/benchmarks/memory.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
|
sample_uniform_task_indices(dataset, num_samples)
staticmethod
Selects a specified number of indices uniformly at random.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset |
ContinualDataset
|
The dataset that is sampled. |
required |
num_samples |
int
|
the number of samples to draw. |
required |
Returns:
Type | Description |
---|---|
List[int]
|
List[int]: The selected dataset indices. |
Source code in sequel/benchmarks/memory.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
update_memory(algo)
Updates the memory by selecting per_task_memory_samples
samples from the current dataset. The selection
process is defined by the groupby
instance attribute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
algo |
BaseAlgorithm
|
the algorithm instance. |
required |
Source code in sequel/benchmarks/memory.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
update_memory_(benchmark, task)
Updates the memory by selecting per_task_memory_samples
samples from the current dataset. The selection
process is defined by the groupby
instance attribute.
Source code in sequel/benchmarks/memory.py
41 42 43 44 45 46 47 48 49 50 51 |
|