-
Notifications
You must be signed in to change notification settings - Fork 158
Gymnasium support #192
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
base: master
Are you sure you want to change the base?
Gymnasium support #192
Changes from 17 commits
a413077
35a420c
e1d7ead
c804fe3
5daca4c
85fe46f
c7d62f7
b51ae32
ffdc311
07c464b
675c978
85c38e1
02048ae
98a4efc
4818545
e3c867c
3f98ef7
b145609
0c770b5
e82663e
04c1dd5
c408b08
03f203f
5614323
4b0494e
e92cc63
420dddb
74198b9
3237561
6f0eac6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,4 +5,4 @@ build/ | |
| dist/ | ||
| .idea/ | ||
| results/ | ||
| examples/gym/results/ | ||
| examples/gymnasium/results/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,7 +75,7 @@ main() { | |
| # pytest does not run with attrs==19.2.0 (https://github.com/pytest-dev/pytest/issues/3280) # NOQA | ||
| "${PYTHON}" -m pip install \ | ||
| 'pytest==4.1.1' 'attrs==19.1.0' 'pytest-xdist==1.26.1' \ | ||
| 'gym[atari,classic_control]==0.19.0' 'optuna' 'zipp==1.0.0' 'pybullet==2.8.1' 'jupyterlab==2.1.5' 'traitlets==5.1.1' 'pyglet==1.5.27' | ||
| 'gymnasium[atari,classic_control]==0.19.0' 'optuna' 'zipp==1.0.0' 'pybullet==2.8.1' 'jupyterlab==2.1.5' 'traitlets==5.1.1' | ||
|
|
||
| git config --global user.email "[email protected]" | ||
| git config --global user.name "Your Name" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,8 +4,8 @@ | |
| # Prevent numpy from using multiple threads | ||
| os.environ["OMP_NUM_THREADS"] = "1" | ||
|
|
||
| import gym # NOQA:E402 | ||
| import gym.wrappers # NOQA:E402 | ||
| import gymnasium # NOQA:E402 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not familiar with gymnasium much, but is it recommended to write
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure. The examples they give often write what you have, but I think it's just to sell the simplicity of their transition from gym to gymnasium. I also think the distinction can help for clarity, so people are reminded which API is being used.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm it does seem even internally in their code they use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. Anyway I agree with your opinion:
|
||
| import gymnasium.wrappers # NOQA:E402 | ||
| import numpy as np # NOQA:E402 | ||
| from torch import nn # NOQA:E402 | ||
|
|
||
|
|
@@ -91,7 +91,7 @@ def main(): | |
| args.outdir = experiments.prepare_output_dir(args, args.outdir) | ||
| print("Output files are saved in {}".format(args.outdir)) | ||
|
|
||
| n_actions = gym.make(args.env).action_space.n | ||
| n_actions = gymnasium.make(args.env).action_space.n | ||
|
|
||
| input_to_hidden = nn.Sequential( | ||
| nn.Conv2d(4, 16, 8, stride=4), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,15 @@ | ||
| # Examples for OpenAI Gym environments | ||
| # Examples for OpenAI gymnasium environments | ||
|
|
||
| - `train_categorical_dqn_gym.py`: CategoricalDQN for discrete action action spaces | ||
| - `train_dqn_gym.py`: DQN for both discrete action and continuous action spaces | ||
| - `train_reinforce_gym.py`: REINFORCE for both discrete action and continuous action spaces (only for episodic envs) | ||
| - `train_categorical_dqn_gymnasium.py`: CategoricalDQN for discrete action action spaces | ||
| - `train_dqn_gymnasium.py`: DQN for both discrete action and continuous action spaces | ||
| - `train_reinforce_gymnasium.py`: REINFORCE for both discrete action and continuous action spaces (only for episodic envs) | ||
|
|
||
| ## How to run | ||
|
|
||
| ``` | ||
| python train_categorical_dqn_gym.py [options] | ||
| python train_dqn_gym.py [options] | ||
| python train_reinforce_gym.py [options] | ||
| python train_categorical_dqn_gymnasium.py [options] | ||
| python train_dqn_gymnasium.py [options] | ||
| python train_reinforce_gymnasium.py [options] | ||
| ``` | ||
|
|
||
| Specify `--help` or read code for options. |
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.
This should be Farama Foundation's gymnasium