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

Example error caused by create_tensor(... keep_dimensions) defaulting to False #219

Open
NoneJou072 opened this issue Oct 28, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@NoneJou072
Copy link

Description

Hello, when I run the example files provided by the [official document] (https://github.com/Toni-SM/skrl/blob/main/docs/source/examples/deepmind/dm_manipulation_stack_sac.py), an error comes as follows.

Traceback (most recent call last):
  File "/home/zhr/zhr/skrl/docs/source/examples/deepmind/dm_manipulation_stack_sac.py", line 179, in <module>
    trainer = SequentialTrainer(cfg=cfg_trainer, env=env, agents=agent_sac)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zhr/zhr/skrl/skrl/trainers/torch/sequential.py", line 55, in __init__
    self.agents.init(trainer_cfg=self.cfg)
  File "/home/zhr/zhr/skrl/skrl/agents/torch/sac/sac.py", line 201, in init
    self.memory.create_tensor(name="states", size=self.observation_space, dtype=torch.float32)
  File "/home/zhr/zhr/skrl/skrl/memories/torch/base.py", line 197, in create_tensor
    size = self._get_space_size(size, keep_dimensions)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zhr/zhr/skrl/skrl/memories/torch/base.py", line 111, in _get_space_size
    raise ValueError("keep_dimensions=True cannot be used with Dict spaces")
ValueError: keep_dimensions=True cannot be used with Dict spaces

The reason was that I used the 'dict' type as the obs space.

I noticed that a similar error was mentioned in https://github.com/Toni-SM/skrl/pull/201. Do you have any temporary solutions for using 'dict' obs space, thanks.

What skrl version are you using?

1.3.0

What ML framework/library version are you using?

Pytorch version

Additional system information

Python 3.10, Ubuntu20.04

@NoneJou072 NoneJou072 added the bug Something isn't working label Oct 28, 2024
@larsrpe
Copy link

larsrpe commented Oct 28, 2024

I am facing the same issues. It does not seem like the Memory class handels dict observations. One work around is to concatenate the observations instead.

@Toni-SM
Copy link
Owner

Toni-SM commented Nov 3, 2024

Hi @NoneJou072 and @larsrpe

Keep dimensions change (set to True) introduced in version 1.3.0 was reverted in develop branch.

keep_dimensions: bool = False) -> bool:

In addition, spaces utilities were added to develop branch to handle fundamental (Box, Discrete and MultiDiscrete) and composite (Tuple and Dict) spaces better.


Please, use the develop branch while the new release is being completed

@larsrpe
Copy link

larsrpe commented Nov 5, 2024

Thank you for the clarification. And sorry for not checking the devleop branch right away! Keep up the good work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants