Skip to content

Commit

Permalink
Replace deprecated optuna.suggest_loguniform(...) by `optuna.sugges…
Browse files Browse the repository at this point in the history
…t_float(..., log=True)` (#362)
  • Loading branch information
qgallouedec authored Mar 2, 2023
1 parent 309ad8c commit d38ef18
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
### Other
- Added support for `ruff` (fast alternative to flake8) in the Makefile
- Removed Gitlab CI file
- Replaced deprecated `optuna.suggest_loguniform(...)` by `optuna.suggest_float(..., log=True)`

## Release 1.7.0 (2023-01-10)

Expand Down
20 changes: 10 additions & 10 deletions rl_zoo3/hyperparams_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ def sample_ppo_params(trial: optuna.Trial) -> Dict[str, Any]:
batch_size = trial.suggest_categorical("batch_size", [8, 16, 32, 64, 128, 256, 512])
n_steps = trial.suggest_categorical("n_steps", [8, 16, 32, 64, 128, 256, 512, 1024, 2048])
gamma = trial.suggest_categorical("gamma", [0.9, 0.95, 0.98, 0.99, 0.995, 0.999, 0.9999])
learning_rate = trial.suggest_loguniform("learning_rate", 1e-5, 1)
learning_rate = trial.suggest_float("learning_rate", 1e-5, 1, log=True)
lr_schedule = "constant"
# Uncomment to enable learning rate schedule
# lr_schedule = trial.suggest_categorical('lr_schedule', ['linear', 'constant'])
ent_coef = trial.suggest_loguniform("ent_coef", 0.00000001, 0.1)
ent_coef = trial.suggest_float("ent_coef", 0.00000001, 0.1, log=True)
clip_range = trial.suggest_categorical("clip_range", [0.1, 0.2, 0.3, 0.4])
n_epochs = trial.suggest_categorical("n_epochs", [1, 5, 10, 20])
gae_lambda = trial.suggest_categorical("gae_lambda", [0.8, 0.9, 0.92, 0.95, 0.98, 0.99, 1.0])
Expand Down Expand Up @@ -86,7 +86,7 @@ def sample_trpo_params(trial: optuna.Trial) -> Dict[str, Any]:
batch_size = trial.suggest_categorical("batch_size", [8, 16, 32, 64, 128, 256, 512])
n_steps = trial.suggest_categorical("n_steps", [8, 16, 32, 64, 128, 256, 512, 1024, 2048])
gamma = trial.suggest_categorical("gamma", [0.9, 0.95, 0.98, 0.99, 0.995, 0.999, 0.9999])
learning_rate = trial.suggest_loguniform("learning_rate", 1e-5, 1)
learning_rate = trial.suggest_float("learning_rate", 1e-5, 1, log=True)
lr_schedule = "constant"
# Uncomment to enable learning rate schedule
# lr_schedule = trial.suggest_categorical('lr_schedule', ['linear', 'constant'])
Expand Down Expand Up @@ -159,8 +159,8 @@ def sample_a2c_params(trial: optuna.Trial) -> Dict[str, Any]:
gae_lambda = trial.suggest_categorical("gae_lambda", [0.8, 0.9, 0.92, 0.95, 0.98, 0.99, 1.0])
n_steps = trial.suggest_categorical("n_steps", [8, 16, 32, 64, 128, 256, 512, 1024, 2048])
lr_schedule = trial.suggest_categorical("lr_schedule", ["linear", "constant"])
learning_rate = trial.suggest_loguniform("learning_rate", 1e-5, 1)
ent_coef = trial.suggest_loguniform("ent_coef", 0.00000001, 0.1)
learning_rate = trial.suggest_float("learning_rate", 1e-5, 1, log=True)
ent_coef = trial.suggest_float("ent_coef", 0.00000001, 0.1, log=True)
vf_coef = trial.suggest_uniform("vf_coef", 0, 1)
# Uncomment for gSDE (continuous actions)
# log_std_init = trial.suggest_uniform("log_std_init", -4, 1)
Expand Down Expand Up @@ -216,7 +216,7 @@ def sample_sac_params(trial: optuna.Trial) -> Dict[str, Any]:
:return:
"""
gamma = trial.suggest_categorical("gamma", [0.9, 0.95, 0.98, 0.99, 0.995, 0.999, 0.9999])
learning_rate = trial.suggest_loguniform("learning_rate", 1e-5, 1)
learning_rate = trial.suggest_float("learning_rate", 1e-5, 1, log=True)
batch_size = trial.suggest_categorical("batch_size", [16, 32, 64, 128, 256, 512, 1024, 2048])
buffer_size = trial.suggest_categorical("buffer_size", [int(1e4), int(1e5), int(1e6)])
learning_starts = trial.suggest_categorical("learning_starts", [0, 1000, 10000, 20000])
Expand Down Expand Up @@ -277,7 +277,7 @@ def sample_td3_params(trial: optuna.Trial) -> Dict[str, Any]:
:return:
"""
gamma = trial.suggest_categorical("gamma", [0.9, 0.95, 0.98, 0.99, 0.995, 0.999, 0.9999])
learning_rate = trial.suggest_loguniform("learning_rate", 1e-5, 1)
learning_rate = trial.suggest_float("learning_rate", 1e-5, 1, log=True)
batch_size = trial.suggest_categorical("batch_size", [16, 32, 64, 100, 128, 256, 512, 1024, 2048])
buffer_size = trial.suggest_categorical("buffer_size", [int(1e4), int(1e5), int(1e6)])
# Polyak coeff
Expand Down Expand Up @@ -335,7 +335,7 @@ def sample_ddpg_params(trial: optuna.Trial) -> Dict[str, Any]:
:return:
"""
gamma = trial.suggest_categorical("gamma", [0.9, 0.95, 0.98, 0.99, 0.995, 0.999, 0.9999])
learning_rate = trial.suggest_loguniform("learning_rate", 1e-5, 1)
learning_rate = trial.suggest_float("learning_rate", 1e-5, 1, log=True)
batch_size = trial.suggest_categorical("batch_size", [16, 32, 64, 100, 128, 256, 512, 1024, 2048])
buffer_size = trial.suggest_categorical("buffer_size", [int(1e4), int(1e5), int(1e6)])
# Polyak coeff
Expand Down Expand Up @@ -391,7 +391,7 @@ def sample_dqn_params(trial: optuna.Trial) -> Dict[str, Any]:
:return:
"""
gamma = trial.suggest_categorical("gamma", [0.9, 0.95, 0.98, 0.99, 0.995, 0.999, 0.9999])
learning_rate = trial.suggest_loguniform("learning_rate", 1e-5, 1)
learning_rate = trial.suggest_float("learning_rate", 1e-5, 1, log=True)
batch_size = trial.suggest_categorical("batch_size", [16, 32, 64, 100, 128, 256, 512])
buffer_size = trial.suggest_categorical("buffer_size", [int(1e4), int(5e4), int(1e5), int(1e6)])
exploration_final_eps = trial.suggest_uniform("exploration_final_eps", 0, 0.2)
Expand Down Expand Up @@ -489,7 +489,7 @@ def sample_ars_params(trial: optuna.Trial) -> Dict[str, Any]:
# n_eval_episodes = trial.suggest_categorical("n_eval_episodes", [1, 2])
n_delta = trial.suggest_categorical("n_delta", [4, 8, 6, 32, 64])
# learning_rate = trial.suggest_categorical("learning_rate", [0.01, 0.02, 0.025, 0.03])
learning_rate = trial.suggest_loguniform("learning_rate", 1e-5, 1)
learning_rate = trial.suggest_float("learning_rate", 1e-5, 1, log=True)
delta_std = trial.suggest_categorical("delta_std", [0.01, 0.02, 0.025, 0.03, 0.05, 0.1, 0.2, 0.3])
top_frac_size = trial.suggest_categorical("top_frac_size", [0.1, 0.2, 0.3, 0.5, 0.8, 0.9, 1.0])
zero_policy = trial.suggest_categorical("zero_policy", [True, False])
Expand Down

0 comments on commit d38ef18

Please sign in to comment.