question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Enhancement] Support Different VecEnvWrapper Depths

See original GitHub issue

Is there a reason that this while loop assumes env and eval_env are wrapped in the same number of VecEnvWrappers? 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:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
araffincommented, May 12, 2021

Is it okay to apply VecMonitor to a VecEnv where each individual env already has Monitor applied? (The VecEnv was created with stable_baselines3.common.env_util.make_vec_env.)

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

0reactions
scottemmonscommented, May 12, 2021

Great - these solutions should work for me!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found