Skip to content
This repository has been archived by the owner on Dec 24, 2024. It is now read-only.

[WIP] Support gym.spaces.Dict #219

Merged
merged 18 commits into from
Apr 2, 2019
Merged

[WIP] Support gym.spaces.Dict #219

merged 18 commits into from
Apr 2, 2019

Conversation

takerfume
Copy link
Contributor

No description provided.

@takerfume
Copy link
Contributor Author

takerfume commented Mar 30, 2019

All that is left is to support a nested dictionary of gym.spaces.Dict like the following example.
This is written in gym.spaces.dict_space.py

Example usage [nested]:
self.nested_observation_space = spaces.Dict({
    'sensors':  spaces.Dict({
        'position': spaces.Box(low=-100, high=100, shape=(3)),
        'velocity': spaces.Box(low=-1, high=1, shape=(3)),
        'front_cam': spaces.Tuple((
            spaces.Box(low=0, high=1, shape=(10, 10, 3)),
            spaces.Box(low=0, high=1, shape=(10, 10, 3))
        )),
        'rear_cam': spaces.Box(low=0, high=1, shape=(10, 10, 3)),
    }),
    'ext_controller': spaces.MultiDiscrete([ [0,4], [0,1], [0,1] ]),
    'inner_state':spaces.Dict({
        'charge': spaces.Discrete(100),
        'system_checks': spaces.MultiBinary(10),
        'job_status': spaces.Dict({
            'task': spaces.Discrete(5),
            'progress': spaces.Box(low=0, high=100, shape=()),
        })
    })
})```

@takerfume
Copy link
Contributor Author

I will leave supporting nested gym.spaces.Dict described my above comment for another PR.
I have finished writing code in this PR.
I have finished writing the following contents.

  • Use gym.wrappers.FlattenDictWrapper in order to transform gym.spaces.Dict to flatten gym.spaces.Box
  • Define the function of machina.envs.flatten_to_dict in order to transform flatten obs to dict obs.
  • Test the consistency of value of obs in tests.test_env.test_flatten2dict
  • Test if dict obs can be used to train ppo and sac in tests.test_env.TestFlatten2DictPP0 and tests.test_env.TestFlatten2DictSAC

@takerfume
Copy link
Contributor Author

@rarilurelo @iory Could you check this PR?

@takerfume
Copy link
Contributor Author

@rarilurelo I added test of r2d2.

@rarilurelo rarilurelo merged commit 646f670 into master Apr 2, 2019
@rarilurelo rarilurelo deleted the support-dict branch April 2, 2019 05:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants