Skip to content

Fix episodic buffer __len__ #155

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

Merged
merged 8 commits into from
Oct 20, 2017
Merged

Conversation

muupan
Copy link
Member

@muupan muupan commented Oct 17, 2017

  • Add AbstractReplayBuffer and AbstractEpisodicReplayBuffer to clarify the interfaces of replay buffers
  • Change the behaviour of the __len__ of EpisodicReplayBuffer and PrioritizedEpisodicReplayBuffer so that they now return the number of transitions, not of episodes.
  • Add the n_episodes property to count the number of episodes
  • Update the examples accordingly
  • Update the tests accordingly (and fix a bug in tests)

Resolves #138

The behaviour of episodic replay buffers has been changed so that now
__len__ returns the number of transitions, not episodes, to fix
chainer#138. You can use the n_episodes
property to get the number of episodes in the buffer.
@coveralls
Copy link

coveralls commented Oct 19, 2017

Coverage Status

Coverage decreased (-0.08%) to 71.629% when pulling b20b2db on muupan:fix-episodic-buffer-len into 570ce6f on chainer:master.

@muupan muupan changed the title [WIP] Fix episodic buffer __len__ Fix episodic buffer __len__ Oct 19, 2017
Copy link
Member

@toslunar toslunar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me except it should be clear which class should take care of size checks. For example, I suppose update_if_necessary should have the same check as the lines you added to PCL.

Besides, I left some suggestions that might improve the code.

def stop_current_episode(self):
"""Notify the buffer that the current episode is interrupted.

When a transtion with is_state_terminal=True is appended, the buffer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest starting the document with the cases when the method should be called, for example:

You may want to interrupt the current episode and start a new one before observing a terminal state. This is typical in continuing envs. In such cases, you need to call this method before appending a new transition so that the buffer will treat it as an initial transition of a new episode.
This method should not be called after an episode whose termination is already notified by appending a transition with is_state_terminal=True.

@@ -14,14 +14,16 @@
from chainerrl.misc.prioritized import PrioritizedBuffer


class ReplayBuffer(object):
class AbstractReplayBuffer(object):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you decorate the methods with @abstractmethod?

@muupan
Copy link
Member Author

muupan commented Oct 20, 2017

Thank you for your review! I added a check of n_episodes in ReplayUpdater.update_if_necessary as well and followed your suggestions.

@toslunar
Copy link
Member

LGTM!

@coveralls
Copy link

coveralls commented Oct 20, 2017

Coverage Status

Coverage decreased (-0.03%) to 71.672% when pulling 3dc1ce5 on muupan:fix-episodic-buffer-len into 570ce6f on chainer:master.

@toslunar toslunar merged commit 51a2762 into chainer:master Oct 20, 2017
@muupan muupan added the bug label Nov 30, 2017
@muupan muupan added this to the v0.3 milestone Nov 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance of ACER compared to A3C
3 participants