mirror of
https://github.com/wassname/pytorch-a2c-ppo-acktr.git
synced 2026-06-27 16:20:05 +08:00
Create an act function
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user