April 2019
Intermediate to advanced
212 pages
5h 34m
English
We're going to put together a basic DQN algorithm that actually progresses through the environment and keeps the CartPole in motion for more than a few steps. We'll build on the performance of this basic algorithm after we see its results, but this will be sufficient to get a solution up and running.
We start by initializing the hyperparameters and the action space:
class DQN: def __init__(self): self.epsilon = epsilon self.gamma = gamma self.alpha = alpha self.action_space = env.action_space.n
We're now creating a three-layer sequential network in Keras using relu activation functions for the input and hidden layers:
self.model = Sequential() self.model.add.(Dense(24, input_shape=(observation_space,), activation=
Read now
Unlock full access