torch.Tensor.Tensor.logaddexp2
Tensor.logaddexp2<O extends Shape>(other: Tensor<O>): Tensor<DynamicShape, D, Dev>Computes the logarithm of the sum of 2^x and 2^y element-wise.
Numerically stable computation of log(2^x + 2^y). This operation is useful in machine learning when dealing with log-space calculations where direct computation would overflow or underflow. Commonly used in:
- Log-space arithmetic for numerical stability
- Probability computations involving sums of exponentials
- Information theory and entropy calculations
This function is numerically stable and avoids overflow/underflow issues that would occur with direct computation
(x.exp2() + y.exp2()).log2().Parameters
otherTensor<O>- Tensor with same shape as this tensor
Returns
Tensor<DynamicShape, D, Dev>– Tensor with element-wise log(2^self + 2^other)Examples
const x = torch.tensor([1.0, 2.0, 3.0]);
const y = torch.tensor([2.0, 1.0, 0.0]);
const result = x.logaddexp2(y); // log(2^x + 2^y)See Also
- PyTorch torch.logaddexp2()
- logaddexp - Log of sum of exponentials