MCPcopy Create free account
hub / github.com/rlcode/reinforcement-learning / __init__

Method __init__

3-atari/2-ppo.py:42–53  ·  view source on GitHub ↗
(self, n_actions)

Source from the content-addressed store, hash-verified

40# Nature CNN shared trunk + policy and value heads.
41class ActorCritic(nn.Module):
42 def __init__(self, n_actions):
43 super().__init__()
44 self.conv = nn.Sequential(
45 _ortho(nn.Conv2d(4, 32, kernel_size=8, stride=4), 2 ** 0.5), nn.ReLU(),
46 _ortho(nn.Conv2d(32, 64, kernel_size=4, stride=2), 2 ** 0.5), nn.ReLU(),
47 _ortho(nn.Conv2d(64, 64, kernel_size=3, stride=1), 2 ** 0.5), nn.ReLU(),
48 nn.Flatten(),
49 _ortho(nn.Linear(64 * 7 * 7, 512), 2 ** 0.5), nn.ReLU(),
50 )
51 # gain=0.01 keeps the initial action distribution close to uniform.
52 self.policy = _ortho(nn.Linear(512, n_actions), 0.01)
53 self.value = _ortho(nn.Linear(512, 1), 1.0)
54
55 def forward(self, x):
56 h = self.conv(x.float() / 255.0)

Callers

nothing calls this directly

Calls 1

_orthoFunction · 0.70

Tested by

no test coverage detected