January 2020
Intermediate to advanced
432 pages
10h 18m
English
Previously, we saw how the DQN class was used to construct the neural network model that we will use to learn the TD loss function. Reopen exercise Chapter_6_DQN.py again to review the construction of the DQN class:
class DQN(nn.Module): def __init__(self, num_inputs, num_actions): super(DQN, self).__init__() self.layers = nn.Sequential( nn.Linear(env.observation_space.shape[0], 128), nn.ReLU(), nn.Linear(128, 128), nn.ReLU(), nn.Linear(128, env.action_space.n)) def forward(self, x): return self.layers(x) def act(self, state, epsilon): if random.random() > epsilon: state = autograd.Variable(torch.FloatTensor(state).unsqueeze(0), volatile=True) q_value = self.forward(state) ...
Read now
Unlock full access