Esempio n. 1
0
 def store_episode(self):
     if self.redis_server is None:
         return
     states, actions, rewards, dones = self.buffer.get_complete_episode()
     episode = [
         states.tolist(),
         actions.tolist(),
         rewards.tolist(),
         dones.tolist()
     ]
     episode = serialize(episode)
     self.redis_server.rpush("trajectories", episode)
     hard_seeds = serialize(list(self.hard_seeds))
     self.redis_server.set(
         f"{self.redis_prefix}_{self._sampler_id}_hard_seeds", hard_seeds)
Esempio n. 2
0
 def update_samplers_weights(self):
     if self.epoch % self.weights_sync_period == 0:
         actor_state_dict = self.algorithm.actor.state_dict()
         actor_state_dict = {
             k: v.tolist() for k, v in actor_state_dict.items()}
         self.redis_server.set(
             f"{self.redis_prefix}_actor_weights",
             serialize(actor_state_dict))
Esempio n. 3
0
def compress(data):
    if LZ4_ENABLED:
        data = serialize(data)
        data = lz4.frame.compress(data)
        data = base64.b64encode(data).decode("ascii")
    return data