Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make seed work again in value methods #134

Merged
merged 3 commits into from
Mar 11, 2022
Merged
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
2 changes: 1 addition & 1 deletion cleanrl/c51.py
Original file line number Diff line number Diff line change
@@ -166,7 +166,7 @@ def linear_schedule(start_e: float, end_e: float, duration: int, t: int):
# ALGO LOGIC: put action logic here
epsilon = linear_schedule(args.start_e, args.end_e, args.exploration_fraction * args.total_timesteps, global_step)
if random.random() < epsilon:
actions = envs.action_space.sample()
actions = np.array([envs.single_action_space.sample() for _ in range(envs.num_envs)])
else:
actions, pmf = q_network.get_action(torch.Tensor(obs).to(device))
actions = actions.cpu().numpy()
2 changes: 1 addition & 1 deletion cleanrl/c51_atari.py
Original file line number Diff line number Diff line change
@@ -187,7 +187,7 @@ def linear_schedule(start_e: float, end_e: float, duration: int, t: int):
# ALGO LOGIC: put action logic here
epsilon = linear_schedule(args.start_e, args.end_e, args.exploration_fraction * args.total_timesteps, global_step)
if random.random() < epsilon:
actions = envs.action_space.sample()
actions = np.array([envs.single_action_space.sample() for _ in range(envs.num_envs)])
else:
actions, pmf = q_network.get_action(torch.Tensor(obs).to(device))
actions = actions.cpu().numpy()
2 changes: 1 addition & 1 deletion cleanrl/ddpg_continuous_action.py
Original file line number Diff line number Diff line change
@@ -161,7 +161,7 @@ def forward(self, x):
for global_step in range(args.total_timesteps):
# ALGO LOGIC: put action logic here
if global_step < args.learning_starts:
actions = envs.action_space.sample()
actions = np.array([envs.single_action_space.sample() for _ in range(envs.num_envs)])
else:
actions = actor(torch.Tensor(obs).to(device))
actions = np.array(
2 changes: 1 addition & 1 deletion cleanrl/dqn.py
Original file line number Diff line number Diff line change
@@ -151,7 +151,7 @@ def linear_schedule(start_e: float, end_e: float, duration: int, t: int):
# ALGO LOGIC: put action logic here
epsilon = linear_schedule(args.start_e, args.end_e, args.exploration_fraction * args.total_timesteps, global_step)
if random.random() < epsilon:
actions = envs.action_space.sample()
actions = np.array([envs.single_action_space.sample() for _ in range(envs.num_envs)])
else:
logits = q_network(torch.Tensor(obs).to(device))
actions = torch.argmax(logits, dim=1).cpu().numpy()
2 changes: 1 addition & 1 deletion cleanrl/dqn_atari.py
Original file line number Diff line number Diff line change
@@ -172,7 +172,7 @@ def linear_schedule(start_e: float, end_e: float, duration: int, t: int):
# ALGO LOGIC: put action logic here
epsilon = linear_schedule(args.start_e, args.end_e, args.exploration_fraction * args.total_timesteps, global_step)
if random.random() < epsilon:
actions = envs.action_space.sample()
actions = np.array([envs.single_action_space.sample() for _ in range(envs.num_envs)])
else:
logits = q_network(torch.Tensor(obs).to(device))
actions = torch.argmax(logits, dim=1).cpu().numpy()
2 changes: 1 addition & 1 deletion cleanrl/sac_continuous_action.py
Original file line number Diff line number Diff line change
@@ -212,7 +212,7 @@ def to(self, device):
for global_step in range(args.total_timesteps):
# ALGO LOGIC: put action logic here
if global_step < args.learning_starts:
actions = envs.action_space.sample()
actions = np.array([envs.single_action_space.sample() for _ in range(envs.num_envs)])
else:
actions, _, _ = actor.get_action(torch.Tensor(obs).to(device))
actions = actions.detach().cpu().numpy()
2 changes: 1 addition & 1 deletion cleanrl/td3_continuous_action.py
Original file line number Diff line number Diff line change
@@ -166,7 +166,7 @@ def forward(self, x):
for global_step in range(args.total_timesteps):
# ALGO LOGIC: put action logic here
if global_step < args.learning_starts:
actions = envs.action_space.sample()
actions = np.array([envs.single_action_space.sample() for _ in range(envs.num_envs)])
else:
actions = actor(torch.Tensor(obs).to(device))
actions = np.array(