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
2 changes: 2 additions & 0 deletions ss2r/algorithms/sac/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def train(
reset_on_eval: bool = True,
store_buffer: bool = False,
use_rae: bool = False,
critic_entropy: bool = True,
):
if min_replay_size >= num_timesteps:
raise ValueError(
Expand Down Expand Up @@ -335,6 +336,7 @@ def train(
safety_budget,
tau,
num_critic_updates_per_actor_update,
critic_entropy=critic_entropy,
)

def prefill_replay_buffer(
Expand Down
5 changes: 4 additions & 1 deletion ss2r/algorithms/sac/training_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def make_training_step(
safety_budget,
tau,
num_critic_updates_per_actor_update,
critic_entropy=True,
):
def critic_sgd_step(
carry: Tuple[TrainingState, PRNGKey], transitions: Transition
Expand All @@ -42,7 +43,9 @@ def critic_sgd_step(

key, key_critic, key_cost_critic = jax.random.split(key, 3)
transitions = float32(transitions)
alpha = jnp.exp(training_state.alpha_params) + min_alpha
alpha = (
jnp.exp(training_state.alpha_params) + min_alpha if critic_entropy else 0.0
)
critic_loss, qr_params, qr_optimizer_state = critic_update(
training_state.qr_params,
training_state.policy_params,
Expand Down
2 changes: 1 addition & 1 deletion ss2r/benchmark_suites/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,5 +448,5 @@ def where_done(x, y):
else:
raise NotImplementedError
new_data = jax.tree.map(where_done, maybe_reset_data, state_data)
obs = jax.tree.map(maybe_reset.obs, state.obs)
obs = jax.tree.map(where_done, maybe_reset.obs, state.obs)
return state.replace(**{data_name: new_data, "obs": obs})
1 change: 1 addition & 0 deletions ss2r/configs/agent/sac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ store_buffer: false
use_rae: false
n_critics: 2
n_heads: 1
critic_entropy: true
9 changes: 6 additions & 3 deletions ss2r/configs/experiment/go1_sim_to_real_rae.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ training:
train_domain_randomization: true
eval_domain_randomization: true
safe: false
wandb_id: 9a3kb4n0
num_envs: 1
num_timesteps: 5000000
wandb_id: 8wuunrrv
num_envs: 2
num_timesteps: 1000000
num_evals: 20
hard_resets: true

environment:
train_params:
Expand Down Expand Up @@ -44,3 +46,4 @@ agent:
num_critic_updates_per_actor_update: 20
n_heads: 10
n_critics: 1
critic_entropy: false