AI4Finance-Foundation / AI4Finance-Foundation/ElegantRL

✨ build vectorized env from single env

Ouverte
#249 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
dicussion
Langage dominant
Python
Étoiles
4.4k
Forks
978
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.