Other

项目介绍

AI4Finance-Foundation/ElegantRL 是一个托管在 GitHub 上的开源项目,主要使用 Python 编写,采用 Other 许可证,目前获得 4.4k 个 Star、965 次 Fork。

仓库全名
AI4Finance-Foundation/ElegantRL
开源许可证
Other
Star 数
4.4k
Fork 数
965
未关闭 Issue
149

README 摘要

ElegantRL “小雅”: Massively Parallel Deep Reinforcement Learning Slack Invitation Link --> ElegantRL is a lightweight and structurally clean reinforcement learning framework designed to express core RL algorithms with minimal complexity and maximal clarity. The name “Elegant” reflects its philosophy: small in dependency footprint, yet elegant in code structure. The framework avoids unnecessary third-party libraries…

完整内容见 GitHub 原始 README 或本页 。

常见问题

ElegantRL 用什么语言开发?

主要使用 Python 编写,采用 Other 许可证,目前有 4.4k 个 Star。

ElegantRL 可以免费商用吗?

仓库标注的许可证为 Other,商用前请先阅读仓库 LICENSE 文件确认授权范围。

如何获取 ElegantRL 的源码?

可以直接克隆仓库:git clone https://github.com/AI4Finance-Foundation/ElegantRL.git,默认分支为 master;安装与运行步骤见仓库 README。

ElegantRL 最近还在维护吗?

仓库最近一次更新为 2月20日,当前有 149 个未关闭 Issue;Star 数为 4.4k,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

Massively Parallel Deep Reinforcement Learning. 🔥

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

语言占比

Jupyter Notebook
Python

Release

README

image

ElegantRL “小雅”: Massively Parallel Deep Reinforcement Learning

Downloads Downloads Python 3.6 PyPI License



ElegantRL is a lightweight and structurally clean reinforcement learning framework designed to express core RL algorithms with minimal complexity and maximal clarity.

The name “Elegant” reflects its philosophy: small in dependency footprint, yet elegant in code structure. The framework avoids unnecessary third-party libraries while maintaining modular design, mathematical transparency, and engineering readability.

ElegantRL focuses on implementing reinforcement learning algorithms in their pure form — clear, extensible, and efficient — without sacrificing performance or simplicity.

Visitors

ElegantRL (website) is developed for users/developers with the following advantages:

  • Cloud-native: follows a cloud-native paradigm through micro-service architecture and containerization, and supports ElegantRL-Podracer and FinRL-Podracer.

  • Scalable: fully exploits the parallelism of DRL algorithms, making it easily scale out to hundreds or thousands of computing nodes on a cloud platform, say, a DGX SuperPOD platform with thousands of GPUs.

  • Elastic: allows to elastically and automatically allocate computing resources on the cloud.

  • Lightweight: the core codes have <1,000 lines (check Elegantrl_Helloworld).

  • Efficient: in many testing cases (e.g., single-GPU/multi-GPU/GPU-cloud), we find it more efficient than Ray RLlib.

  • Stable: much much much more stable than Stable Baselines 3 by utilizing various methods such as the Hamiltonian term.

  • Practical: used in multipe projects (FinRL, FinRL-Meta, etc.)

  • Massively parallel simulations are used in multipe projects (FinRL, etc.); therefore, the sampling speed is high since we can build many many GPU-based environments.

ElegantRL implements the following model-free deep reinforcement learning (DRL) algorithms:

  • DDPG, TD3, SAC, PPO, REDQ for continuous actions in single-agent environment,
  • DQN, Double DQN, D3QN for discrete actions in single-agent environment,
  • QMIX, VDN, MADDPG, MAPPO, MATD3 in multi-agent environment.

For more details of DRL algorithms, please refer to the educational webpage OpenAI Spinning Up.

ElegantRL supports the following simulators:

  • Isaac Gym for massively parallel simulations,
  • OpenAI Gym, MuJoCo, PyBullet, FinRL for benchmarking.

Contents

Tutorials

ElegantRL-Helloworld

For beginners, we maintain ElegantRL-Helloworld as a tutorial. Its goal is to get hands-on experience with ELegantRL.

One sentence summary: an agent (agent.py) with Actor-Critic networks (net.py) is trained (run.py) by interacting with an environment (env.py).

File Structure

  • elegantrl # main folder

    • agents # a collection of DRL algorithms
      • AgentXXX.py # a collection of one kind of DRL algorithms
      • net.py # a collection of network architectures
    • envs # a collection of environments
    • train # a collection of training programs - demo.py # a collection of demos
      • config.py # configurations (hyper-parameter)
      • run.py # training loop
      • worker.py # the worker class (explores the env, saving the data to replay buffer)
      • learner.py # the learner class (update the networks, using the data in replay buffer)
      • evaluator.py # the evaluator class (evaluate the cumulative rewards of policy network)
      • replay_buffer.py # the buffer class (save sequences of transitions for training)
  • elegantrl_helloworld # tutorial version

  • examples # a collection of example codes

  • ready-to-run Google-Colab notebooks

    • quickstart_Pendulum_v1.ipynb
    • tutorial_BipedalWalker_v3.ipynb
    • tutorial_Creating_ChasingVecEnv.ipynb
    • tutorial_LunarLanderContinuous_v2.ipynb
  • unit_tests # a collection of tests

Experimental Demos

More efficient than Ray RLlib

Experiments on Ant (MuJoCo), Humainoid (MuJoCo), Ant (Isaac Gym), Humanoid (Isaac Gym) # from left to right

ElegantRL fully supports Isaac Gym that runs massively parallel simulation (e.g., 4096 sub-envs) on one GPU.

More stable than Stable-baseline 3

Experiment on Hopper-v2 # ElegantRL achieves much smaller variance (average over 8 runs).

Also, PPO+H in ElegantRL completed the training process of 5M samples about 6x faster than Stable-Baseline3.

Testing and Contributing

Our tests are written with the built-in unittest Python module for easy access. In order to run a specific test file (for example, test_training_agents.py), use the following command from the root directory:

python -m unittest unit_tests/test_training_agents.py

In order to run all the tests sequentially, you can use the following command:

python -m unittest discover

Please note that some of the tests require Isaac Gym to be installed on your system. If it is not, any tests related to Isaac Gym will fail.

We welcome any contributions to the codebase, but we ask that you please do not submit/push code that breaks the tests. Also, please shy away from modifying the tests just to get your proposed changes to pass them. As it stands, the tests on their own are quite minimal (instantiating environments, training agents for one step, etc.), so if they’re breaking, it’s almost certainly a problem with your code and not with the tests.

We’re actively working on refactoring and trying to make the codebase cleaner and more performant as a whole. If you’d like to help us clean up some code, we’d strongly encourage you to also watch Uncle Bob’s clean coding lessons if you haven’t already.

Requirements

Necessary:
| Python 3.6+     |
| PyTorch 1.6+    |

Not necessary:
| Numpy 1.18+     | For ReplayBuffer. Numpy will be installed along with PyTorch.
| gym 0.17.0      | For env. Gym provides tutorial env for DRL training. (env.render() bug in gym==0.18 pyglet==1.6. Change to gym==0.17.0, pyglet==1.5)
| pybullet 2.7+   | For env. We use PyBullet (free) as an alternative of MuJoCo (not free).
| box2d-py 2.3.8  | For gym. Use pip install Box2D (instead of box2d-py)
| matplotlib 3.2  | For plots.

pip3 install gym==0.17.0 pybullet Box2D matplotlib # or pip install -r requirements.txt

To install StarCraftII env,
bash ./elegantrl/envs/installsc2.sh
pip install -r sc2_requirements.txt

Citation:

To cite this repository:

@misc{erl,
  author = {Liu, Xiao-Yang and Li, Zechu and Zhu, Ming and Wang, Zhaoran and Zheng, Jiahao},
  title = {{ElegantRL}: Massively Parallel Framework for Cloud-native Deep Reinforcement Learning},
  year = {2021},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/AI4Finance-Foundation/ElegantRL}},
}
@article{liu2021elegantrl,
  title={ElegantRL-Podracer: Scalable and elastic library for cloud-native deep reinforcement learning},
  author={Liu, Xiao-Yang and Li, Zechu and Yang, Zhuoran and Zheng, Jiahao and Wang, Zhaoran and Walid, Anwar and Guo, Jian and Jordan, Michael I},
  journal={NeurIPS, Workshop on Deep Reinforcement Learning},
  year={2021}
}

评论

暂无评论