AI4Finance-Foundation / ElegantRL

Massively Parallel Deep Reinforcement Learning. 🔥
https://ai4finance.org
Other
3.56k stars 819 forks source link

The method how to use Vectorized Env in ElegantRL #168

Open Xiong5Heng opened 2 years ago

Xiong5Heng commented 2 years ago

Firstly, thanks for your excellent work. Recently, I plan to apply ElegantRL in my research work, and I'm trying to accelerate training and sampling process with SubprocVecEnv in Stable Baselines 3. However, I didn't find any doc and example about it in ElegantRL tutorial. So is it possible to combine ElegantRL with SubprocVecEnv and how to do it?

Yonv1943 commented 2 years ago

I'll write down some short answers and then wait until tonight to refine.


Stable Baselines 3 SubprocVecEnv is a vectorized environment. Isaac Gym is a vectorized environment too. We had vectorized environment demo in demo_Isaac_Gym.py

https://github.com/AI4Finance-Foundation/ElegantRL/blob/1fadb93eebb7abcfff76679636c9bb0b12170ca4/examples/demo_Isaac_Gym.py#L17

To use SB3's VecEnv feature, we can start by changing Isaac Gym's VecEnv demo code.

https://github.com/AI4Finance-Foundation/ElegantRL/blob/1fadb93eebb7abcfff76679636c9bb0b12170ca4/elegantrl/agents/AgentBase.py#L73-L76