[Enhancement] Support Different VecEnvWrapper Depths
See original GitHub issueIs there a reason that this while loop assumes env
and eval_env
are wrapped in the same number of VecEnvWrapper
s?
https://github.com/DLR-RM/stable-baselines3/blob/2ada2dd0b2b10f71d0be38ce032d49391b875c4e/stable_baselines3/common/vec_env/__init__.py#L66
This assumption is causing a bug for me in one of my use cases. The following code relaxes this assumption and fixes my use case:
while isinstance(env_tmp, VecEnvWrapper) or isinstance(eval_env_tmp, VecEnvWrapper)
if isinstance(env_tmp, VecNormalize):
eval_env_tmp.obs_rms = deepcopy(env_tmp.obs_rms)
eval_env_tmp.ret_rms = deepcopy(env_tmp.ret_rms)
try:
env_tmp = env_tmp.venv
except AttributeError:
pass
try:
eval_env_tmp = eval_env_tmp.venv
except AttributeError:
pass
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Vectorized Environments - Stable Baselines3 - Read the Docs
Vectorized Environments are a method for stacking multiple independent environments into a single environment. Instead of training an RL agent on 1 environment ......
Read more >Curriculum Reinforcement Learning for Goal-Oriented Robot ...
Learning (CuRL) as a method to help solve these complex tasks by ... An untrained robot could cause damage to itself or other...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It is unless you have some low level wrappers that changes the reward: https://github.com/DLR-RM/stable-baselines3/blob/master/stable_baselines3/common/vec_env/vec_monitor.py#L43
Great - these solutions should work for me!