Closed vwxyzjn closed 2 years ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Updated |
---|---|---|---|
cleanrl | ✅ Ready (Inspect) | Visit Preview | Aug 26, 2022 at 1:54AM (UTC) |
@dosssma, @yooceii, @Dipamc77 would you mind giving this a try? See https://cleanrl-jlu83xh5n-vwxyzjn.vercel.app/advanced/hyperparameter-tuning/ for the current tutorial. Would love to hear your feedback.
@vwxyzjn Thanks for the great addition.
Tried to follow up the instructions to get it to work, but there were a few snags along the way:
The poetry rule to install optuna do not seem present. Also, in the docs, shouldn't it be something like poetry install -E optuna
instead of the current poetry install optuna
? For now, I just installed it using pip install optuna
to test the scripts at least.
Running pip install optuna
did not seem to be enough. I also had to run pip install rich
to tuner_example.py
to at least start.
A bit tangential to this hyparam search feature, but in the Cleanrl starting documentation, it is started that the library requires either python 3.8 or 3.9. (See corresponding single comment)
I have yet to test other tuner scripts than tyner_example.py
, but it looks good so far.
Thanks will definitely add the dependencies in poetry - I just try to do this in the last step due to the potential poetry conflicts with other branches. Glad to hear tuner_example.py
is working fine.
Haven't been able to run the code yet, but I read the code, here are some thoughts.
The minimum and maximum reward being required beforehand is a bit of a limitation. Though it's not clear to me that normalization is needed when running on a single environment. If it isn’t maybe it can be left optional or at least stated in the docs so that anyone trying a new env doesn’t need to provide them.
Should link to the documentation of what other samplers are available under trial that is passed to sampler_fn
Faced the same situation that dossman@ have when installing optuna. but other than that. Example works. Wonder if it's better to do the hyperparameter sweep that works for multiple env or individual env as different env might have different optimal parameter settings.
Thanks, @Dipamc77 @dosssman @yooceii @kinalmehta for the review
The minimum and maximum reward being required beforehand is a bit of a limitation.
Addressed. Users can put target_scores = {"CartPole-v1": None}
Should link to the documentation of what other samplers are available under trial that is passed to sampler_fn
Done and added another API to pass user specified sampler.
Wonder if it's better to do the hyperparameter sweep that works for multiple env or individual env as different env might have different optimal parameter settings.
If the users want to do that, they could probably create multiple instances of the tuner like
from cleanrl_utils.tuner import Tuner
tuner = Tuner(
script="cleanrl/ppo.py",
metric="charts/episodic_return",
metric_last_n_average_window=50,
direction="maximize",
target_scores={
"CartPole-v1": None,
},
params_fn=lambda trial: {
"learning-rate": trial.suggest_loguniform("learning-rate", 0.0003, 0.003),
"num-minibatches": trial.suggest_categorical("num-minibatches", [1, 2, 4]),
"update-epochs": trial.suggest_categorical("update-epochs", [1, 2, 4]),
"num-steps": trial.suggest_categorical("num-steps", [5, 16, 32, 64, 128]),
"vf-coef": trial.suggest_uniform("vf-coef", 0, 5),
"max-grad-norm": trial.suggest_uniform("max-grad-norm", 0, 5),
"total-timesteps": 10000,
"num-envs": 4,
},
)
tuner.tune(
num_trials=100,
num_seeds=3,
)
tuner = Tuner(
script="cleanrl/ppo.py",
metric="charts/episodic_return",
metric_last_n_average_window=50,
direction="maximize",
target_scores={
"Acrobat-v1": None,
},
params_fn=lambda trial: {
"learning-rate": trial.suggest_loguniform("learning-rate", 0.0003, 0.003),
"num-minibatches": trial.suggest_categorical("num-minibatches", [1, 2, 4]),
"update-epochs": trial.suggest_categorical("update-epochs", [1, 2, 4]),
"num-steps": trial.suggest_categorical("num-steps", [5, 16, 32, 64, 128]),
"vf-coef": trial.suggest_uniform("vf-coef", 0, 5),
"max-grad-norm": trial.suggest_uniform("max-grad-norm", 0, 5),
"total-timesteps": 10000,
"num-envs": 4,
},
)
tuner.tune(
num_trials=100,
num_seeds=3,
)
Refactored the documentation a bit to help users better get started. Merging now.
Any chance anyone wants to explain the biggest advantage of Optuna over wandb's hyperparameter optimization? The latter's practically already built-in.
(Btw thanks for a great library!)
Hi @braham-snyder, Wanda’s hyperparameter optimization is great. I have used it before and it’s easy to use.
Feature-wise optuna does support more functionalities. E.g., pruning less promising experiments or multi objective optimization.
Thanks!
Description
This PR adds a first pass of hyperparameter optimization.
The API design roughly looks like
Preliminary docs are available at https://cleanrl-jlu83xh5n-vwxyzjn.vercel.app/advanced/hyperparameter-tuning/
Types of changes
Checklist:
pre-commit run --all-files
passes (required).mkdocs serve
.