torch.distributions
Modules
Functions
- greater_than - Creates a constraint for values strictly greater than a lower bound.
- greater_than_eq - Creates a constraint for values greater than or equal to a lower bound.
- less_than - Creates a constraint for values strictly less than an upper bound.
- interval - Creates a constraint for values in an open interval (lower_bound, upper_bound).
- half_open_interval - Creates a constraint for values in a half-open interval [lower_bound, upper_bound).
- integer_interval - Creates a constraint for integer values in a closed interval [lower_bound, upper_bound].
- independent - Create an independent constraint.
- stack - Creates a constraint that applies multiple constraints to stacked tensor dimensions.
- register_kl - Register a KL divergence function for a pair of distribution types.
- kl_divergence - Compute the Kullback-Leibler (KL) divergence between two distributions.
- toTensor - Convert a number or tensor to a tensor.
- broadcast_all - Broadcasts multiple tensors and scalars to a common compatible shape.
- extendedShape - Compute the extended shape for sampling.
- clampTensor - Clamp a tensor to a range.
- probs_to_logits - Converts probabilities to logits (log-odds).
- logits_to_probs - Converts logits (log-odds) to probabilities.
- lazy_property - Decorator for lazy-loaded computed properties with automatic caching.
- sumRightmost - Sum out the rightmost n dimensions of a tensor.
- getDeviceFromTensors - Get the device from a list of tensors.
- getDTypeFromTensors - Get the dtype from a list of tensors.
Constraint
- check - Check if a value satisfies this constraint.
- toString - String representation of the constraint.
Distribution
- set_default_validate_args - Sets whether validation is enabled or disabled globally.
- sample - Generate samples from the distribution.
- rsample - Generate reparameterized samples (gradients flow through).
- sample_n - Generate n samples.
- log_prob - Compute log probability of value under the distribution.
- cdf - Compute the cumulative distribution function at value.
- icdf - Compute the inverse cumulative distribution function.
- entropy - Compute entropy of the distribution.
- perplexity - Compute perplexity of the distribution: exp(entropy()).
- enumerate_support - Enumerate all values in the support.
- expand - Returns a new distribution with batch dimensions expanded.
- toString - String representation for debugging.
ExponentialFamily
- entropy - Computes entropy using Bregman divergence formula.
Types
- ArgConstraints - Type for argument constraints mapping parameter names to constraints.
- StackOptions - Options for stack and _Stack
- StudentTOptions - Options for StudentT distribution.
- DistributionOptions - Options for distribution construction.
- SampleOptions - Options for sampling.
- EnumerateSupportOptions - Options for enumerate_support.
- ExpandOptions - Options for expand.
- ClampOptions - Options for clampTensor
- ProbsToLogitsOptions - Options for probs_to_logits
- LogitsToProbsOptions - Options for logits_to_probs