Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data type for Spaces #527

Closed
el3ment opened this issue Mar 9, 2017 · 5 comments
Closed

Data type for Spaces #527

el3ment opened this issue Mar 9, 2017 · 5 comments

Comments

@el3ment
Copy link

el3ment commented Mar 9, 2017

I think the various spaces objects should have a dtype property that specifies the correct type. This will make creating tensorflow placeholders and database-like structures that are memory efficient.

For example a Box(low=0, high=255, shape(255, 255, 3)) could have Box(low=0, high=255, shape(255, 255, 3), dtype=np.uint8) . This would allow someone to use env.observation_space.dtype in a meaningful way.

@tlbtlbtlb
Copy link
Contributor

There is a dtype, at env.observation_space.lo.dtype. Unfortunately all the envs implicitly set it to np.float64 even if their observations are bytes.

In practice, all my agents end up converting bytes to floats before using them in tensorflow, at least because I want to multiply by 1.0/255.0 to get normalized values.

But it seems reasonable to have pixel-based envs set the dtype to np.uint8.

@hholst80
Copy link

A proper serialization format would be nice for all gym.spaces

@tlbtlbtlb
Copy link
Contributor

@hholst80 Pickle should work for all spaces and points in the space.
Additionally, spaces have a .to_jsonable method if you want to exchange data with non-Python programs.

@hholst80
Copy link

@tlbtlbtlb .to_jsonable only works with samples from the space not for the actual space class itself.

But Pickle could be a good solution. Too bad its hard to use between C# and Python. If we could serialize it to a dict we could easily use json to serialize it over network / between applications.

@tlbtlbtlb
Copy link
Contributor

To interchange data with other languages, consider the gym-http-api package. It has a JSON representation of spaces, as well as everything else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants