Create an act function

This commit is contained in:
Ilya Kostrikov
2017-09-22 12:29:21 -04:00
parent 6c949f291e
commit f4fc4c6064
2 changed files with 10 additions and 6 deletions
+7
View File
@@ -77,3 +77,10 @@ class ActorCritic(torch.nn.Module):
return self.ab_fc2(self.critic_linear(x)), self.ab_fc3(
self.actor_linear(x))
def act(self, inputs):
value, logits = self(inputs)
probs = F.softmax(logits)
action = probs.multinomial()
action_log_probs = F.log_softmax(logits).gather(1, action)
return value, action, action_log_probs