MCPcopy Index your code
hub / github.com/pytorch/tutorials / ReplayMemory

Class ReplayMemory

intermediate_source/reinforcement_q_learning.py:138–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136
137
138class 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######################################################################

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected