Skip to content

Commit

Permalink
prioritized experience replay bug (#527)
Browse files Browse the repository at this point in the history
  • Loading branch information
xffxff authored and pzhokhov committed Sep 20, 2018
1 parent 0f4ae2f commit 7859f60
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions baselines/deepq/replay_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ def add(self, *args, **kwargs):

def _sample_proportional(self, batch_size):
res = []
for _ in range(batch_size):
# TODO(szymon): should we ensure no repeats?
mass = random.random() * self._it_sum.sum(0, len(self._storage) - 1)
p_total = self._it_sum.sum(0, len(self._storage) - 1)
every_range_len = p_total / batch_size
for i in range(batch_size):
mass = random.random() * every_range_len + i * every_range_len
idx = self._it_sum.find_prefixsum_idx(mass)
res.append(idx)
return res
Expand Down

0 comments on commit 7859f60

Please sign in to comment.