Example error caused by create_tensor(... keep_dimensions) defaulting to False
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
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.
Hi @NoneJou072 and @larsrpe
Keep dimensions change (set to True) introduced in version 1.3.0 was reverted in develop branch.
https://github.com/Toni-SM/skrl/blob/eff72951a4522e1a237e8a6df200b89fc6656a75/skrl/memories/torch/base.py#L132
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
Thank you for the clarification. And sorry for not checking the devleop branch right away! Keep up the good work!
Fixed in version 1.4.0: https://github.com/Toni-SM/skrl/blob/d57c8ea138e3356396a8da368f37430f75fb524a/CHANGELOG.md?plain=1#L21