Fix GDumb bug
@@ -28,7 +28,8 @@ class GDumbPlugin(StrategyPlugin):
# count occurrences for each class
self.counter = defaultdict(lambda: defaultdict(int))
- def adapt_train_dataset(self, strategy, **kwargs):
+ def after_train_dataset_adaptation(self, strategy: 'BaseStrategy',
+ **kwargs):
""" Before training we make sure to organize the memory following
GDumb approach and updating the dataset accordingly.
"""
@@ -52,9 +53,10 @@ class GDumbPlugin(StrategyPlugin):
if target_value not in current_counter or \
current_counter[target_value] < patterns_per_class:
+ # add new pattern into memory
+ if sum(current_counter.values()) >= self.mem_size:
# full memory: replace item from most represented class
# with current pattern
- if sum(current_counter.values()) >= self.mem_size:
to_remove = max(current_counter, key=current_counter.get)
for j in range(len(current_mem.tensors[1])):
if current_mem.tensors[1][j].item() == to_remove:
@@ -81,4 +83,4 @@ class GDumbPlugin(StrategyPlugin):
current_counter[target_value] += 1
self.ext_mem[strategy.experience.task_label] = current_mem
- strategy.adapted_dataset = AvalancheConcatDataset(self.ext_mem)
+ strategy.adapted_dataset = AvalancheConcatDataset(self.ext_mem.values())
