Skip to content

Commit 951dbec

Browse files
committed
initial commit
1 parent 5386dcc commit 951dbec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+4038
-0
lines changed

.gitignore

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# Created by https://www.gitignore.io/api/python,windows,visualstudiocode
2+
# Edit at https://www.gitignore.io/?templates=python,windows,visualstudiocode
3+
4+
# My ignores
5+
script.sh
6+
*logs*
7+
logfile
8+
*output*
9+
*DS_Store*
10+
job_idx_*
11+
procfile
12+
13+
### Python ###
14+
# Byte-compiled / optimized / DLL files
15+
__pycache__/
16+
*.py[cod]
17+
*$py.class
18+
19+
# C extensions
20+
*.so
21+
22+
# Distribution / packaging
23+
.Python
24+
build/
25+
develop-eggs/
26+
dist/
27+
downloads/
28+
eggs/
29+
.eggs/
30+
lib/
31+
lib64/
32+
parts/
33+
sdist/
34+
var/
35+
wheels/
36+
pip-wheel-metadata/
37+
share/python-wheels/
38+
*.egg-info/
39+
.installed.cfg
40+
*.egg
41+
MANIFEST
42+
43+
# PyInstaller
44+
# Usually these files are written by a python script from a template
45+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
46+
*.manifest
47+
*.spec
48+
49+
# Installer logs
50+
pip-log.txt
51+
pip-delete-this-directory.txt
52+
53+
# Unit test / coverage reports
54+
htmlcov/
55+
.tox/
56+
.nox/
57+
.coverage
58+
.coverage.*
59+
.cache
60+
nosetests.xml
61+
coverage.xml
62+
*.cover
63+
.hypothesis/
64+
.pytest_cache/
65+
66+
# Translations
67+
*.mo
68+
*.pot
69+
70+
# Django stuff:
71+
*.log
72+
local_settings.py
73+
db.sqlite3
74+
75+
# Flask stuff:
76+
instance/
77+
.webassets-cache
78+
79+
# Scrapy stuff:
80+
.scrapy
81+
82+
# Sphinx documentation
83+
docs/_build/
84+
85+
# PyBuilder
86+
target/
87+
88+
# Jupyter Notebook
89+
.ipynb_checkpoints
90+
91+
# IPython
92+
profile_default/
93+
ipython_config.py
94+
95+
# pyenv
96+
.python-version
97+
98+
# pipenv
99+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
100+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
101+
# having no cross-platform support, pipenv may install dependencies that don’t work, or not
102+
# install all needed dependencies.
103+
#Pipfile.lock
104+
105+
# celery beat schedule file
106+
celerybeat-schedule
107+
108+
# SageMath parsed files
109+
*.sage.py
110+
111+
# Environments
112+
.env
113+
.venv
114+
env/
115+
venv/
116+
ENV/
117+
env.bak/
118+
venv.bak/
119+
120+
# Spyder project settings
121+
.spyderproject
122+
.spyproject
123+
124+
# Rope project settings
125+
.ropeproject
126+
127+
# mkdocs documentation
128+
/site
129+
130+
# mypy
131+
.mypy_cache/
132+
.dmypy.json
133+
dmypy.json
134+
135+
# Pyre type checker
136+
.pyre/
137+
138+
### VisualStudioCode ###
139+
.vscode
140+
!.vscode/settings.json
141+
!.vscode/tasks.json
142+
!.vscode/launch.json
143+
!.vscode/extensions.json
144+
145+
### VisualStudioCode Patch ###
146+
# Ignore all local history of files
147+
.history
148+
149+
### Windows ###
150+
# Windows thumbnail cache files
151+
Thumbs.db
152+
ehthumbs.db
153+
ehthumbs_vista.db
154+
155+
# Dump file
156+
*.stackdump
157+
158+
# Folder config file
159+
[Dd]esktop.ini
160+
161+
# Recycle Bin used on file shares
162+
$RECYCLE.BIN/
163+
164+
# Windows Installer files
165+
*.cab
166+
*.msi
167+
*.msix
168+
*.msm
169+
*.msp
170+
171+
# Windows shortcuts
172+
*.lnk
173+
174+
# End of https://www.gitignore.io/api/python,windows,visualstudiocode

README.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Jaxplorer
2+
3+
Jaxplorer is a Jax reinforcement learning framework for **exploring** new ideas.
4+
For PyTorch reinforcement learning framework, please check [Explorer](https://github.com/qlan3/Explorer).
5+
6+
Note: this repo is still under development and in its early stage.
7+
8+
## Requirements
9+
10+
- Python: 3.11
11+
- [Jax](https://jax.readthedocs.io/en/latest/installation.html): >=0.4.20
12+
- [Gymnasium](https://github.com/Farama-Foundation/Gymnasium): pip install gymnasium==0.29.1
13+
- [Mujoco](https://github.com/google-deepmind/mujoco): pip install mujoco==2.3.7
14+
- [Gymnasium(mujoco)](https://gymnasium.farama.org/environments/mujoco/): pip install gymnasium[mujoco]
15+
- Others: Please check `requirements.txt`.
16+
17+
18+
## Implemented algorithms
19+
20+
- [Deep Q-Learning (DQN)](https://users.cs.duke.edu/~pdinesh/sources/MnihEtAlHassibis15NatureControlDeepRL.pdf)
21+
- [Double Deep Q-learning (DDQN)](https://arxiv.org/pdf/1509.06461.pdf)
22+
- [Maxmin Deep Q-learning (MaxminDQN)](https://arxiv.org/pdf/2002.06487.pdf)
23+
- [Proximal Policy Optimisation (PPO)](https://arxiv.org/pdf/1707.06347.pdf)
24+
- [Soft Actor-Critic (SAC)](https://arxiv.org/pdf/1812.05905.pdf)
25+
- [Deep Deterministic Policy Gradients (DDPG)](https://arxiv.org/pdf/1509.02971.pdf)
26+
- [Twin Delayed Deep Deterministic Policy Gradients (TD3)](https://arxiv.org/pdf/1802.09477.pdf)
27+
- [Continuous Deep Q-Learning with Model-based Acceleration (NAF)](https://arxiv.org/pdf/1603.00748.pdf): model-free version; a different exploration strategy is applied for simplicity.
28+
29+
TODO: add more algorithms and improve the performance of PPO.
30+
31+
## Experiments
32+
33+
### Train && Test
34+
35+
All hyperparameters including parameters for grid search are stored in a configuration file in directory `configs`. To run an experiment, a configuration index is first used to generate a configuration dict corresponding to this specific configuration index. Then we run an experiment defined by this configuration dict. All results including log files are saved in directory `logs`. Please refer to the code for details.
36+
37+
For example, run the experiment with configuration file `classic_dqn.json` and configuration index `1`:
38+
39+
```python main.py --config_file ./configs/classic_dqn.json --config_idx 1```
40+
41+
The models are tested for one episode after every `test_per_episodes` training episodes which can be set in the configuration file.
42+
43+
44+
### Grid Search (Optional)
45+
46+
First, we calculate the number of total combinations in a configuration file (e.g. `classic_dqn.json`):
47+
48+
`python utils/sweeper.py`
49+
50+
The output will be:
51+
52+
`Number of total combinations in classic_dqn.json: 18`
53+
54+
Then we run through all configuration indexes from `1` to `18`. The simplest way is using a bash script:
55+
56+
``` bash
57+
for index in {1..18}
58+
do
59+
python main.py --config_file ./configs/classic_dqn.json --config_idx $index
60+
done
61+
```
62+
63+
[Parallel](https://www.gnu.org/software/parallel/) is usually a better choice to schedule a large number of jobs:
64+
65+
``` bash
66+
parallel --eta --ungroup python main.py --config_file ./configs/classic_dqn.json --config_idx {1} ::: $(seq 1 18)
67+
```
68+
69+
Any configuration index that has the same remainder (divided by the number of total combinations) should have the same configuration dict. So for multiple runs, we just need to add the number of total combinations to the configuration index. For example, 5 runs for configuration index `1`:
70+
71+
```
72+
for index in 1 19 37 55 73
73+
do
74+
python main.py --config_file ./configs/classic_dqn.json --config_idx $index
75+
done
76+
```
77+
78+
Or a simpler way:
79+
```
80+
parallel --eta --ungroup python main.py --config_file ./configs/classic_dqn.json --config_idx {1} ::: $(seq 1 18 90)
81+
```
82+
83+
### Slurm (Optional)
84+
85+
Slurm is supported as well. Please check `submit.py`.
86+
TODO: add more details.
87+
88+
89+
### Analysis (Optional)
90+
91+
To analyze the experimental results, just run:
92+
93+
`python analysis.py`
94+
95+
Inside `analysis.py`, `unfinished_index` will print out the configuration indexes of unfinished jobs based on the existence of the result file. `memory_info` will print out the memory usage information and generate a histogram to show the distribution of memory usages in directory `logs/classic_dqn/0`. Similarly, `time_info` will print out the time information and generate a histogram to show the distribution of time in directory `logs/classic_dqn/0`. Finally, `analyze` will generate `csv` files that store training and test results. Please check `analysis.py` for more details. More functions are available in `utils/plotter.py`.
96+
97+
TODO: add more details about hyper-parameter comparison.
98+
99+
100+
## Cite
101+
102+
If you find this repo useful to your research, please cite my paper if related. Otherwise, please cite this repo:
103+
104+
~~~bibtex
105+
@misc{Jaxplorer,
106+
author = {Lan, Qingfeng},
107+
title = {A Jax Reinforcement Learning Framework for Exploring New Ideas},
108+
year = {2024},
109+
publisher = {GitHub},
110+
journal = {GitHub Repository},
111+
howpublished = {\url{https://github.com/qlan3/Jaxplorer}}
112+
}
113+
~~~
114+
115+
# Acknowledgements
116+
117+
- [Explorer](https://github.com/qlan3/Explorer)
118+
- [Jax RL](https://github.com/ikostrikov/jaxrl)
119+
- [CleanRL](https://github.com/vwxyzjn/cleanrl)

0 commit comments

Comments
 (0)