AI4Finance-Foundation / AI4Finance-Foundation/ElegantRL

✨ build vectorized env from single env

Offen
#249 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
dicussion
Vorherrschende Sprache
Python
Sterne
4.4k
Forks
978
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.