Skip to content

[Feature Request] MultiDiscreteTensorSpec #781

Closed

Description

@matteobettini

Motivation

Currently there are the following avaialble specs for discrete spaces:

OneHotDiscreteTensorSpec # One hot for one discrete action
MultOneHotDiscreteTensorSpec # One hot for n actions
DiscreteTensorSpec # Categorical integer for one action

It would be nice to introduce the remaining missing spec MultiDiscreteTensorSpec for n categorical actions.

This would allow the _gym_to_torchrl_spec_transform to use this new spec with the parameter categorical_action_encoding to decide which space to assign to gym.spaces.MultIDiscrete doing somethig like this:

    elif isinstance(spec, gym.spaces.multi_discrete.MultiDiscrete):
        return    MultiDiscreteTensorSpec(spec.nvec, device=device)  if categorical_action_encoding
            else MultOneHotDiscreteTensorSpec(spec.nvec, device=device)

as it is already done for gym.spaces.Discrete.

Furthermore it would be nice for these discrete classes to possess the methods to_onehot() and to_categorical() respectively.

Activity

  1. added
    enhancement
    on Jan 1, 2023
  2. riiswa commented on Jan 1, 2023

    @riiswa
    Contributor

    @matteobettini will you work on it? If not I would like to work on it 😄

  3. matteobettini commented on Jan 1, 2023

    @matteobettini
    ContributorAuthor

    I have a few thing in my hands these days, so I do not know when I could start on this. if you want to do it, go for it :) it would be super helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions