From 5a959f125570491719c92868168cd372e4323549 Mon Sep 17 00:00:00 2001 From: Reinis Cimurs <33617541+reiniscimurs@users.noreply.github.com> Date: Wed, 17 Aug 2022 21:25:18 +0200 Subject: [PATCH] Delete replay_buffer2.py --- TD3/replay_buffer2.py | 51 ------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 TD3/replay_buffer2.py diff --git a/TD3/replay_buffer2.py b/TD3/replay_buffer2.py deleted file mode 100644 index 31745741..00000000 --- a/TD3/replay_buffer2.py +++ /dev/null @@ -1,51 +0,0 @@ -""" -Data structure for implementing experience replay -Author: Patrick Emami -""" -from collections import deque -import random -import numpy as np - -class ReplayBuffer(object): - - def __init__(self, buffer_size, random_seed=123): - """ - The right side of the deque contains the most recent experiences - """ - self.buffer_size = buffer_size - self.count = 0 - self.buffer = deque() - random.seed(random_seed) - - def add(self, s, a, r, t, s2): - experience = (s, a, r, t, s2) - if self.count < self.buffer_size: - self.buffer.append(experience) - self.count += 1 - else: - self.buffer.popleft() - self.buffer.append(experience) - - def size(self): - return self.count - - def sample_batch(self, batch_size): - batch = [] - - if self.count < batch_size: - batch = random.sample(self.buffer, self.count) - else: - batch = random.sample(self.buffer, batch_size) - - s_batch = np.array([_[0] for _ in batch]) - a_batch = np.array([_[1] for _ in batch]) - r_batch = np.array([_[2] for _ in batch]).reshape(-1,1) - t_batch = np.array([_[3] for _ in batch]).reshape(-1,1) - s2_batch = np.array([_[4] for _ in batch]) - - return s_batch, a_batch, r_batch, t_batch, s2_batch - - - def clear(self): - self.buffer.clear() - self.count = 0 \ No newline at end of file