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

unflatten always gives 0 class #1196

Open
wadmes opened this issue Sep 16, 2024 · 0 comments
Open

unflatten always gives 0 class #1196

wadmes opened this issue Sep 16, 2024 · 0 comments

Comments

@wadmes
Copy link

wadmes commented Sep 16, 2024

from gymnasium.spaces import Dict, Box, Discrete
from gymnasium import spaces
observation_space = Dict({"position": Box(-1, 1, shape=(2,)), "color": Discrete(5)}, seed=42)
flatten = spaces.flatten_space(observation_space)
obs1 = flatten.sample()
unflat = spaces.utils.unflatten(observation_space,obs1)
print(obs1)
print(unflat)

obs1:

array([ 0.47568119,  0.64470851,  0.93992918,  0.0658021 ,  0.74573835,
        0.68031875, -0.96546865])

unflat:

OrderedDict({'color': 0, 'position': array([ 0.6803188 , -0.96546865], dtype=float32)})

The result of unflat will always gives color = 0, even though it is not in obs1`

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

1 participant