torch.distributions.less_than
function less_than(upper_bound: number): _LessThanCreates a constraint for values strictly less than an upper bound.
Returns a constraint that validates whether tensor values satisfy x < upper_bound. Useful for:
- Probability parameters (must be < 1)
- Rate parameters with upper limits
- Ensuring values stay within valid ranges
- Constraining probabilities and proportions
- Strict inequality: Uses (not =), excluding the boundary value
- Open interval: Defines constraint for interval (-∞, upper_bound)
- Upper bound only: No lower bound checking (use interval for both)
Parameters
upper_boundnumber- The upper bound value (values must be strictly less than this)
Returns
_LessThan– A constraint object that validates x upper_boundExamples
const probability = torch.distributions.constraints.less_than(1.0);
const probs = torch.tensor([0.2, 0.5, 0.9]);
probability.check(probs); // Validates all values < 1.0
// Value equal to upper bound fails
const one = torch.tensor([1.0]);
probability.check(one); // Returns falseSee Also
- PyTorch torch.distributions.constraints.less_than()
- greater_than - Lower bound constraint
- interval - Two-sided interval constraint
- constraints - Other available constraints