-
Notifications
You must be signed in to change notification settings - Fork 600
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
Hyperparameter optimization #228
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@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:
I have yet to test other tuner scripts than |
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 |
Haven't been able to run the code yet, but I read the code, here are some thoughts.
|
Faced the same situation that dossman@ have when installing optuna. but other than that. Example works. |
Thanks, @Dipamc77 @dosssman @yooceii @kinalmehta for the review
Addressed. Users can put
Done and added another API to pass user specified sampler.
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,
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good to me.
Tested the tuner_example and it is working out of the box.
I had to abort it quite early though.
Great work.
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
.