Beispiel #1
0
 def test_replay_balanced_memory(self):
     mem_size = 25
     policies = [
         None,
         ExperienceBalancedBuffer(max_size=mem_size),
         ClassBalancedBuffer(max_size=mem_size),
     ]
     for policy in policies:
         self._test_replay_balanced_memory(policy, mem_size)
Beispiel #2
0
    def __init__(
        self,
        mem_size: int = 200,
        storage_policy: Optional["ExemplarsBuffer"] = None,
        force_data_batch_size: int = None,
    ):
        super().__init__()
        self.mem_size = mem_size
        self.force_data_batch_size = force_data_batch_size

        if storage_policy is not None:  # Use other storage policy
            self.storage_policy = storage_policy
            assert storage_policy.max_size == self.mem_size
        else:  # Default
            self.storage_policy = ExperienceBalancedBuffer(
                max_size=self.mem_size, adaptive_size=True)
Beispiel #3
0
    def __init__(self,
                 mem_size: int = 200,
                 batch_size: int = None,
                 batch_size_mem: int = None,
                 task_balanced_dataloader: bool = False,
                 storage_policy: Optional["ExemplarsBuffer"] = None):
        super().__init__()
        self.mem_size = mem_size
        self.batch_size = batch_size
        self.batch_size_mem = batch_size_mem
        self.task_balanced_dataloader = task_balanced_dataloader

        if storage_policy is not None:  # Use other storage policy
            self.storage_policy = storage_policy
            assert storage_policy.max_size == self.mem_size
        else:  # Default
            self.storage_policy = ExperienceBalancedBuffer(
                max_size=self.mem_size, adaptive_size=True)
Beispiel #4
0
    def test_balancing(self):
        p1 = ExperienceBalancedBuffer(100, adaptive_size=True)
        p2 = ClassBalancedBuffer(100, adaptive_size=True)

        for policy in [p1, p2]:
            self.assert_balancing(policy)