Skip to content

MemoryCallback

MemoryMechanismCallback

Bases: AlgoCallback

Wraps an AlgoCallback around the MemoryMechanism for ease of use.

Source code in sequel/utils/callbacks/memory_callback.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class MemoryMechanismCallback(AlgoCallback):
    """Wraps an AlgoCallback around the MemoryMechanism for ease of use."""

    def __init__(self, per_task_memory_samples: int, groupby: str = "class"):
        super().__init__()
        self.memory = MemoryMechanism(per_task_memory_samples, groupby)
        self.per_task_memory_samples = per_task_memory_samples
        self.groupby = groupby

    def on_after_training_task(self, algo: "BaseAlgorithm", *args, **kwargs):
        """Updates the memory Mechanism.

        Args:
            algo (BaseAlgorithm): The current BaseAlgorithm instance.
        """
        self.memory.update_memory(algo)
        algo.update_episodic_memory()

on_after_training_task(algo, *args, **kwargs)

Updates the memory Mechanism.

Parameters:

Name Type Description Default
algo BaseAlgorithm

The current BaseAlgorithm instance.

required
Source code in sequel/utils/callbacks/memory_callback.py
19
20
21
22
23
24
25
26
def on_after_training_task(self, algo: "BaseAlgorithm", *args, **kwargs):
    """Updates the memory Mechanism.

    Args:
        algo (BaseAlgorithm): The current BaseAlgorithm instance.
    """
    self.memory.update_memory(algo)
    algo.update_episodic_memory()