October 2018
Beginner
362 pages
9h 32m
English
We'll give our training function a simple name: train. First, we'll feed it mini-batches of data from the replay memory:
def train(self): ''' Training procedure for the Q Network''' minibatch = random.sample(self.replayBuffer, 32) stateBatch = [data[0] for data in minibatch] actionBatch = [data[1] for data in minibatch] rewardBatch = [data[2] for data in minibatch] nextBatch = [data[3] for data in minibatch]
Next, we'll calculate the Q-value for each batch:
batch = [] qBatch = self.QValueT.eval(feed_dict = {self.inputValT: nextBatch}) for i in range(0, 32): terminal = minibatch[i][4] if terminal: batch.append(rewardBatch[i]) else: batch.append(rewardBatch[i] + self.gamma * np.max(qBatch[i]))
Now, let's bind this all together ...
Read now
Unlock full access