October 2019
Intermediate to advanced
340 pages
8h 39m
English
We solve the Mountain Car problem using DDQNs as follows:
>>> import gym >>> import torch >>> from collections import deque >>> import random >>> from torch.autograd import Variable >>> import torch.nn as nn >>> env = gym.envs.make("MountainCar-v0")
>>> class DuelingModel(nn.Module): ... def __init__(self, n_input, n_output, n_hidden): ... super(DuelingModel, self).__init__() ... self.adv1 = nn.Linear(n_input, n_hidden) ... self.adv2 = nn.Linear(n_hidden, n_output) ... self.val1 = nn.Linear(n_input, n_hidden) ... self.val2 = nn.Linear(n_hidden, 1) ... ... def forward(self, x): ... adv = nn.functional.relu(self.adv1(x)) ...
Read now
Unlock full access