AI4Finance-Foundation / AI4Finance-Foundation/ElegantRL

✨ build vectorized env from single env

Đang mở
#249 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
dicussion
Ngôn ngữ chính
Python
Star
4.4k
Fork
978
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

The [subprocess Vectorized environment of stable baselines 3](https://stable-baselines3.readthedocs.io/en/master/guide/vec_envs.html) is practically useful.

So I added a simple **subprocess Vectorized environment** into ElegantRL.

Demo code: Add the `num_envs=int` and `if_build_vec_env=True` to the `env_args` for a single env. Then **function `build_env()` **will build a vectorized env automatically.
https://github.com/AI4Finance-Foundation/ElegantRL/blob/003572d9a37a1a302edb8bebd4fbd9c17d5ddccd/examples/demo_A2C_PPO.py#L62-L72

**Function `build_env()`** build a vectorized env from a single env **using `class VecEnv`**:
Build a vectorized env from a single env:
https://github.com/AI4Finance-Foundation/ElegantRL/blob/003572d9a37a1a302edb8bebd4fbd9c17d5ddccd/elegantrl/train/config.py#L112-L124

The **vectorized env `class VecEnv`** is a simplify version of subprocess Vectorized environment for ElegantRL.
`VecEnv` build a vectorized env on GPU. The sub-env number is `num_envs`.

https://github.com/AI4Finance-Foundation/ElegantRL/blob/003572d9a37a1a302edb8bebd4fbd9c17d5ddccd/elegantrl/train/config.py#L245-L248

`VecEnv` use `multiprocessing.Pipe` for communication between `VecEnv` and `SubEnv`:
https://github.com/AI4Finance-Foundation/ElegantRL/blob/003572d9a37a1a302edb8bebd4fbd9c17d5ddccd/elegantrl/train/config.py#L267-L271

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.