def create_default_memory(self): return prioritized_replay_buffer.PrioritizedReplayBuffer( SCREEN_SIZE, STACK_SIZE, REPLAY_CAPACITY, BATCH_SIZE, max_sample_attempts=10) # For faster tests.
def testSampleIndexBatch(self): memory = prioritized_replay_buffer.PrioritizedReplayBuffer( STACK_SIZE, REPLAY_CAPACITY, BATCH_SIZE, max_sample_attempts=10) # This will ensure we end up with cursor == 1. for _ in range(REPLAY_CAPACITY - STACK_SIZE + 2): self.add_blank(memory) self.assertEqual(memory.cursor(), 1) samples = memory.sample_index_batch(REPLAY_CAPACITY) # Because cursor == 1, the invalid range as set by circular_replay_buffer.py # will be # [0, 1, 2, 3], resulting in all samples being in # [STACK_SIZE, REPLAY_CAPACITY - 1]. for sample in samples: self.assertGreaterEqual(sample, STACK_SIZE) self.assertLessEqual(sample, REPLAY_CAPACITY - 1)