-
Notifications
You must be signed in to change notification settings - Fork 526
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
Allow python script for hyperparameter configuration #318
Conversation
Hello, EDIT: my main motivation for keeping yaml files is that they are easy to read (no quotes everywhere) and it's easy to extend hyperparameters that work for some env. |
Is that the only motivation? Because that we could easily do with python dicts. Eg use the kwargs notation to create the config dicts like this: hyperparams = {
"atari": dict(
env_wrapper=['stable_baselines3.common.atari_wrappers.AtariWrapper'],
frame_stack=4,
policy="CnnPolicy",
n_envs=16,
n_timesteps=10000000.0,
ent_coef=0.01,
vf_coef=0.25,
policy_kwargs=dict(optimizer_class=RMSpropTFLike, optimizer_kwargs=dict(eps=1e-05))
)
} and we can easily extend/inherit configs like this: mujoco_config = dict(...)
halfcheetah = mujoco_config.copy()
halfcheetah.update(
vf_coef = 0.5
) If you want to stay backwards compatible that is fine but if not then I would prefer minimizing the codebase instead. |
It is true that you can have it a bit cleaner, but it still comes with some overhead notations and can be parsed with python script only.
This is also another important motivation.
I think it should be pretty minimal to support both, no? |
ff4ea0f
to
c296d54
Compare
You are right. It should not be too much work/extra code. |
btw, do you have a convert script? or did you do the conversion by hand? EDIT: for now, I would only put an example python script and keep the right as-is |
I only half-automated this with the interactive console and then did some manual tweaks (turning the strings to evaluate into dicts). |
c296d54
to
d5a53e5
Compare
Hmm I can't replicate the flake8 error in the pipeline locally. @araffin do you have an idea what this could be? |
yep, not your fault... https://stackoverflow.com/questions/74558565/flake8-error-code-supplied-to-ignore-option-does-not-match-a-z1-30 A new version of flake8 was released https://flake8.pycqa.org/en/latest/release-notes/6.0.0.html |
I hope that my PR for flake8 will get merged too https://github.com/PyCQA/flake8/compare/main...araffin:flake8:fix/improve-error-message?expand=1 (but currently all external contribution is prohibited) |
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.
Please update the README for documentation and we are good to go ;)
it does work because the saved yaml file contains the correct imports? |
Yes I think so. Whatever you would put into |
…oo into yaml_to_py_config # Conflicts: # CHANGELOG.md
…he python file instead of package.
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.
LGTM, thanks =)
Description
The yaml files with the hyperparameters are replaced by python files.
The python files must contain a dictionary called
hyperparams
with a key for each environment mapping to hyperparameter configurations.Motivation and Context
The yaml file format had severe limitations in terms of expressiveness such that we already were often resorting to evaluating strings in the yaml file. This lead to problems when the referenced classes ware not imported before.
Just loading the configuration as a dictionary from a python file (in which the appropriate includes can just be added at the top) makes all those hacks obsolete.
We could then also remove the
--gym-packages
parameter!Would fix #316 , would advance #299 and maybe make #315 obsolete.
Types of changes
Checklist:
make format
(required)make check-codestyle
andmake lint
(required)make pytest
andmake type
both pass. (required)Note: we are using a maximum length of 127 characters per line