| 136 | |
| 137 | |
| 138 | class ReplayMemory(object): |
| 139 | |
| 140 | def __init__(self, capacity): |
| 141 | self.memory = deque([], maxlen=capacity) |
| 142 | |
| 143 | def push(self, *args): |
| 144 | """Save a transition""" |
| 145 | self.memory.append(Transition(*args)) |
| 146 | |
| 147 | def sample(self, batch_size): |
| 148 | return random.sample(self.memory, batch_size) |
| 149 | |
| 150 | def __len__(self): |
| 151 | return len(self.memory) |
| 152 | |
| 153 | |
| 154 | ###################################################################### |
no outgoing calls
no test coverage detected