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

[Feature] Add deterministic_sample to masked categorical #2708

Open
wants to merge 3 commits into
base: gh/vmoens/73/base
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update
[ghstack-poisoned]
  • Loading branch information
vmoens committed Jan 21, 2025
commit 6ef147e99b13a6e5e071b1309f9063f28445c771
4 changes: 4 additions & 0 deletions torchrl/modules/distributions/discrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ def _mask_logits(
logits.masked_fill_(padding_mask, neg_inf)
return logits

@property
def deterministic_sample(self):
return self.mode


class MaskedOneHotCategorical(MaskedCategorical):
"""MaskedCategorical distribution.
Expand Down
Loading