Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cleanrl/rpo_continuous_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ def get_action_and_value(self, x, action=None):
probs = Normal(action_mean, action_std)
if action is None:
action = probs.sample()
else: # new to RPO
else: # new to RPO
# sample again to add stochasticity to the policy
z = torch.FloatTensor(action_mean.shape).uniform_(-self.rpo_alpha, self.rpo_alpha)
action_mean = action_mean + z
probs = Normal(action_mean, action_std)

return action, probs.log_prob(action).sum(1), probs.entropy().sum(1), self.critic(x)


Expand Down
10 changes: 10 additions & 0 deletions tests/test_mujoco.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,13 @@ def test_mujoco():
shell=True,
check=True,
)
subprocess.run(
"python cleanrl/rpo_continuous_action.py --env-id Hopper-v4 --num-envs 1 --num-steps 64 --total-timesteps 128",
shell=True,
check=True,
)
subprocess.run(
"python cleanrl/rpo_continuous_action.py --env-id dm_control/cartpole-balance-v0 --num-envs 1 --num-steps 64 --total-timesteps 128",
shell=True,
check=True,
)