rl
rl copied to clipboard
[BUG] Problems with multidimensional `nvec` in `MultiCategorical`
a = MultiCategorical([[3, 2],[1,4]])
a.to_one_hot_spec()
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniforge/base/envs/torchrl-3.11/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 3577, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-28-5f9b780d3aaa>", line 1, in <module>
a.to_one_hot_spec()
File "/Users/Matteo/PycharmProjects/torchrl/torchrl/data/tensor_specs.py", line 3935, in to_one_hot_spec
nvec = [_space.n for _space in self.space]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Matteo/PycharmProjects/torchrl/torchrl/data/tensor_specs.py", line 3935, in <listcomp>
nvec = [_space.n for _space in self.space]
^^^^^^^^
AttributeError: 'BoxList' object has no attribute 'n'
It might be worth checking if in general this spec is compatible with multidimensional nvecs
Solution to this is needed to support #2485