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

[BUG] MaskedCategorical missing mode and deterministic_sample properties. #2479

Open
MorganeAyle opened this issue Oct 9, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@MorganeAyle
Copy link

MorganeAyle commented Oct 9, 2024

Describe the bug

Similar issue as here. The MaskedCategorical distribution is missing the mode and deterministic_sample properties.

Reason and Possible fixes

The MaskedCategorical distribution should define the following additional properties:

@property
def mode(self) -> torch.Tensor:
    if hasattr(self, "logits"):
        return self.logits.max(-1, keepdim=True)[1]
    return self.probs.max(-1, keepdim=True)[1]

@property
def deterministic_sample(self) -> torch.Tensor:
    return self.mode
@MorganeAyle MorganeAyle added the bug Something isn't working label Oct 9, 2024
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

2 participants