Skip to content

Commit

Permalink
Fix for RuntimeError while using single continuous action environment.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aakarshan-chauhan committed Apr 10, 2021
1 parent d83918a commit b27f936
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion PPO.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,14 @@ def evaluate(self, state, action):

if self.has_continuous_action_space:
action_mean = self.actor(state)

action_var = self.action_var.expand_as(action_mean)
cov_mat = torch.diag_embed(action_var).to(device)
dist = MultivariateNormal(action_mean, cov_mat)
else:
action_probs = self.actor(state)
dist = Categorical(action_probs)

action = action.reshape(-1, self.action_dim)
action_logprobs = dist.log_prob(action)
dist_entropy = dist.entropy()
state_values = self.critic(state)
Expand Down

0 comments on commit b27f936

Please sign in to comment.