torch.Tensor.Tensor.greater_equal
Tensor.greater_equal(other: number): Tensor<S, 'bool', Dev>Tensor.greater_equal<O extends Shape>(other: Tensor<O>): Tensor<DynamicShape, 'bool', Dev>Alias for ge() - element-wise greater-than-or-equal comparison.
Returns a boolean tensor indicating which elements are greater than or equal to the comparison value. Useful for:
- Threshold detection (passing grade, minimum score)
- Range checking (is value at least X?)
- Filtering and masking operations
- Conditional logic in computation graphs
- Creating binary masks for selective operations
- Comparison is element-wise; broadcasting applies if shapes differ
- Result is always a boolean tensor, not 0/1
- For NaN: any comparison with NaN returns false
Parameters
othernumber- Scalar or tensor to compare with (broadcasts to match shape)
Returns
Tensor<S, 'bool', Dev>– Boolean tensor where true indicates self[i] = other[i]Examples
// Compare with scalar
const x = torch.tensor([1, 2, 3, 4]);
const result = x.greater_equal(3); // [false, false, true, true]
// Compare two tensors
const a = torch.tensor([1, 5, 3]);
const b = torch.tensor([2, 4, 3]);
a.greater_equal(b); // [false, true, true]
// Threshold detection - passing grades
const scores = torch.tensor([85, 92, 78, 88]);
const passing = scores.greater_equal(80); // [true, true, false, true]
// Use as mask for selection
const data = torch.randn(10);
const positive_mask = data.greater_equal(0);
const positive_values = data.masked_select(positive_mask);See Also
- PyTorch torch.greater_equal()
- ge - Canonical name for this operation
- less - Less than comparison
- equal - Equality comparison
- masked_select - Select elements using boolean mask