Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stratified sampling is not used in PrioritizedReplayBuffer #108

Open
muupan opened this issue Dec 16, 2020 · 0 comments
Open

Stratified sampling is not used in PrioritizedReplayBuffer #108

muupan opened this issue Dec 16, 2020 · 0 comments

Comments

@muupan
Copy link
Member

muupan commented Dec 16, 2020

According to Appendix B.2.1 of the PER paper (http://arxiv.org/abs/1511.05952), the original PER implementation uses stratified sampling:

To sample a minibatch of size k, the range [0, ptotal] is divided equally into k ranges. Next, a value is uniformly sampled from each range. Finally the transitions that correspond to each of these sampled values are retrieved from the tree.

This is different from what PFRL's PrioritizedReplayBuffer does right now, i.e., sampling proportionally without replacement k times:

root = self.root
ixl, ixr = self.bounds
for _ in range(n):
ix = _find(ixl, ixr, root, np.random.uniform(0.0, root[2]))
val = self._write(ix, 0.0)
ixs.append(ix)
vals.append(val)

It is not clear if stratified sampling leads to better performance. In a sense PFRL's way could be better since it can strictly prevent the same minnibatch from having duplicate transitions. However, the difference should be noted, and it is good to support and evaluate stratified sampling as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant