1
0
mirror of https://github.com/gryf/coach.git synced 2026-03-14 21:53:32 +01:00

Adding initial interface for backend and redis pubsub (#19)

* Adding initial interface for backend and redis pubsub

* Addressing comments, adding super in all memories

* Removing distributed experience replay
This commit is contained in:
Ajay Deshpande
2018-10-03 15:07:48 -07:00
committed by zach dwiel
parent a54ef2757f
commit 6b2de6ba6d
21 changed files with 459 additions and 444 deletions

View File

@@ -160,6 +160,8 @@ class EpisodicExperienceReplay(Memory):
:param transition: a transition to store
:return: None
"""
# Calling super.store() so that in case a memory backend is used, the memory backend can store this transition.
super().store(transition)
self.reader_writer_lock.lock_writing_and_reading()
if len(self._buffer) == 0:
@@ -181,6 +183,9 @@ class EpisodicExperienceReplay(Memory):
:param episode: the new episode to store
:return: None
"""
# Calling super.store() so that in case a memory backend is used, the memory backend can store this episode.
super().store(episode)
if lock:
self.reader_writer_lock.lock_writing_and_reading()

View File

@@ -106,6 +106,10 @@ class EpisodicHindsightExperienceReplay(EpisodicExperienceReplay):
]
def store_episode(self, episode: Episode, lock: bool=True) -> None:
# Calling super.store() so that in case a memory backend is used, the memory backend can store this episode.
super().store_episode(episode)
# generate hindsight transitions only when an episode is finished
last_episode_transitions = copy.copy(episode.transitions)

View File

@@ -59,6 +59,10 @@ class EpisodicHRLHindsightExperienceReplay(EpisodicHindsightExperienceReplay):
# for a layer producing sub-goals, we will replace in hindsight the action (sub-goal) given to the lower
# level with the actual achieved goal. the achieved goal (and observation) seen is assumed to be the same
# for all levels - we can use this level's achieved goal instead of the lower level's one
# Calling super.store() so that in case a memory backend is used, the memory backend can store this episode.
super().store_episode(episode)
for transition in episode.transitions:
new_achieved_goal = transition.next_state[self.goals_space.goal_name]
transition.action = new_achieved_goal