torch.Tensor.Tensor.isneginf
Checks for negative infinity.
Returns a boolean tensor where true indicates the corresponding element is -Infinity. Useful for directional overflow detection.
Use Cases:
- Detecting negative overflow separately from positive
- Identifying divergence in specific directions
- Asymmetric error handling
- Underflow diagnosis
- Floating point: Only meaningful for floating point dtypes
- Directional: Detects only negative infinity, not positive
- Return type: Always returns boolean tensor
Returns
Tensor<S, D, Dev>– Boolean tensor where true indicates -InfinityExamples
// Detect negative overflow
const x = torch.tensor([1.0, Infinity, -Infinity, 2.0]);
x.isneginf(); // [false, false, true, false]
// Count overflow directions
const values = torch.tensor([Infinity, -Infinity, 1.0]);
const posCount = values.isposinf().sum().item(); // 1
const negCount = values.isneginf().sum().item(); // 1See Also
- PyTorch torch.isneginf()
- isposinf - Check for positive infinity
- isinf - Check for any infinity
- isfinite - Check for finite values