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.

Support Tuple and Dict spaces

See original GitHub issue

If the obs_space of an environment is a spaces.Tuple, then DummyVecEnc breaks.

class DummyVecEnv(VecEnv):
    def __init__(self, env_fns):
        self.envs = [fn() for fn in env_fns]
        env = self.envs[0]
        VecEnv.__init__(self, len(env_fns), env.observation_space, env.action_space)
        obs_space = env.observation_space
 
        self.keys, shapes, dtypes = obs_space_info(obs_space)       
        self.buf_obs = { k: np.zeros((self.num_envs,) + tuple(shapes[k]), dtype=dtypes[k]) for k in self.keys }

This breaks because self.keys is None. This happens when obs_space is spaces.Tuple, given that spaces.Tuple is not instance of spaces.Dict, and therefore obs_space_info returns [None], {None: None}, {None: None}. So, I’m not sure how to use the DummyVecEnv now…

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Atcoldcommented, Sep 9, 2018

Alright, spaces.Dict are also not supported. I’ve patched it. If anyone is interested, here’s my patch.

https://github.com/Atcold/baselines/commit/dbc329f28c968fc261f53ebafc9f53192caf967c

0reactions
joshim5commented, May 22, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

Choosing between List, Tuple and Dictionary - Medium
List, Tuple and Dictionary are three of the popular data structures that are used by beginners to advanced programmers to store data.
Read more >
Functions with Tuples and Dictionaries Mixed-Up Code ...
Create a function called dict_to_tup_of_tuples that takes in dictionary as a parameter and returns a tuple that contains tuples with the first value...
Read more >
How to use the gym.spaces.Dict function in gym - Snyk
To help you get started, we've selected a few gym examples, based on popular ways it is used in public projects. Secure your...
Read more >
Differences and Applications of List, Tuple, Set and Dictionary ...
Tuple : A Tuple is a collection of Python objects separated by commas. In some ways, a tuple is similar to a list...
Read more >
compiler_gym.spaces — CompilerGym 0.2.5 documentation
Additional spaces: Commandline. Dict. Discrete. NamedDiscrete. Permutation. Reward. Scalar. SpaceSequence. Sequence. Tuple ...
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