pytorch / pytorch/rl

[BUG] Problems with multidimensional `nvec` in `MultiCategorical`

Open
#2,486 0 comments 0 reactions 1 assignee View on GitHub

@vmoens is already working on this.

Since Oct 10, 2024.

bug
Dominant language
Python
Stars
3.6k
Forks
487
Avg merge
1d 1h
Merged PRs (30d)
207

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.