Skip to content

How to code wrapper for envs returning a dictionary of tensors of the observation? #185

Answered by Toni-SM
ErcBunny asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @ErcBunny

Since memory only support tensors (not collection of tensors: dict, tuples, etc.) it is necessary to convert the observation dict (assuming it is a gymnasium.space.Dict space) as flattened tensor in the wrapper. Then, in the model, you can map the flattened tensor to the gymnasium space again using the Model.tensor_to_space method.

For converting the space to flattened tensor see the gymnasium wrapper _observation_to_tensor method used in

observation = self._observation_to_tensor(observation)

Also, see the DeepMind Manipulation: Reach Site Vision dm_manipulation_stack_sac.py example that sho…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ErcBunny
Comment options

@Toni-SM
Comment options

Answer selected by ErcBunny
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants