class
OneHotCategoricalStraightThrough
extends
OneHotCategoricalOneHotCategoricalStraightThrough(probs: Tensor | None = None, logits: Tensor | None = None, validate_args: bool | None = None)Reparameterisable OneHotCategorical based on the straight-through gradient estimator.
Uses the straight-through estimator (Bengio et al., 2013): the forward pass
returns a discrete one-hot sample while the backward pass propagates
gradients through probs.
Parameters
Non-negative probability vector
(..., K). Normalised internally.
Mutually exclusive with logits.Unnormalised log-probabilities
(..., K). Mutually exclusive with
probs.validate_ argsbool | None= NoneIf
True, validate parameter constraints at construction time.Used by 1
Instance methods
2Return a new OneHotCategoricalStraightThrough with batch dimensions expanded.
Draw one-hot samples with straight-through gradients through probs.