MCPcopy Create free account
hub / github.com/pytorch/examples / Policy

Class Policy

reinforcement_learning/reinforce.py:31–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29
30
31class Policy(nn.Module):
32 def __init__(self):
33 super(Policy, self).__init__()
34 self.affine1 = nn.Linear(4, 128)
35 self.dropout = nn.Dropout(p=0.6)
36 self.affine2 = nn.Linear(128, 2)
37
38 self.saved_log_probs = []
39 self.rewards = []
40
41 def forward(self, x):
42 x = self.affine1(x)
43 x = self.dropout(x)
44 x = F.relu(x)
45 action_scores = self.affine2(x)
46 return F.softmax(action_scores, dim=1)
47
48
49policy = Policy()

Callers 1

reinforce.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected