Last active
December 1, 2019 22:05
-
-
Save davidADSP/49ae97f57e7ff6c18b8922f8fe6ee740 to your computer and use it in GitHub Desktop.
replay_buffer.sample_batch (https://arxiv.org/src/1911.08265v1/anc/pseudocode.py)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ReplayBuffer(object): | |
def __init__(self, config: MuZeroConfig): | |
self.window_size = config.window_size | |
self.batch_size = config.batch_size | |
self.buffer = [] | |
def sample_batch(self, num_unroll_steps: int, td_steps: int): | |
games = [self.sample_game() for _ in range(self.batch_size)] | |
game_pos = [(g, self.sample_position(g)) for g in games] | |
return [(g.make_image(i), g.history[i:i + num_unroll_steps], | |
g.make_target(i, num_unroll_steps, td_steps, g.to_play())) | |
for (g, i) in game_pos] | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment