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.

Converting OpenAI vectorized env to stable baselines vectorized env?

See original GitHub issue

I am trying to take an openai baselines environment (vectorized procgen env) and convert it to a stable baselines vectorized environment. Below is my naive attempt. I get the following error that it expects a function, but I am not sure how to resolve the issue. Any help is appreciated.

from procgen import ProcgenEnv

from baselines.common.vec_env import (
    VecExtractDictObs,
    VecMonitor,
    VecFrameStack,
    VecNormalize
)

venv = ProcgenEnv(num_envs=200, env_name="coinrun")

venv = VecExtractDictObs(venv, "rgb")

venv = VecMonitor(venv=venv, filename=None, keep_buf=200,)

venv = VecNormalize(venv=venv, ob=False)

venv = DummyVecEnv(venv)

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-36f973b40ef0> in <module>
     16 venv = VecNormalize(venv=venv, ob=False)
     17 
---> 18 venv = DummyVecEnv(venv)

~/Documents/drl/research/venv_proc/lib/python3.6/site-packages/stable_baselines/common/vec_env/dummy_vec_env.py in __init__(self, env_fns)
     18 
     19     def __init__(self, env_fns):
---> 20         self.envs = [fn() for fn in env_fns]
     21         env = self.envs[0]
     22         VecEnv.__init__(self, len(env_fns), env.observation_space, env.action_space)

TypeError: 'VecNormalize' object is not iterable```

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:17

github_iconTop GitHub Comments

2reactions
araffincommented, Jan 28, 2020

You have to create a wrapper similar to VecExtractDictObs that extracts the “rgb” item from the observation dictionary each environment individually.

this already exist: https://github.com/openai/gym/blob/master/gym/wrappers/filter_observation.py

0reactions
araffincommented, Jul 20, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Vectorized Environments - Stable Baselines - Read the Docs
Creates a simple vectorized wrapper for multiple environments, calling each environment in sequence on the current Python process. This is useful for ...
Read more >
Examples — Stable Baselines 2.10.3a0 documentation
Following example demonstrates reading parameters, modifying some of them and loading them to model by implementing evolution strategy for solving CartPole-v1 ...
Read more >
Vectorized Environments - Stable Baselines3 - Read the Docs
Creates a simple vectorized wrapper for multiple environments, calling each environment in sequence on the current Python process. This is useful for ...
Read more >
Stable Baselines Documentation
Vectorized Environments are a method for multiprocess training. Instead of training an RL agent on 1 environment,.
Read more >
Vectorized Environments - Stable Baselines - Read the Docs
Vectorized Environments are a method for multiprocess training. Instead of training an RL agent on 1 environment, it allows us to train it...
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