megengine.functional.logaddexp¶
- logaddexp(x, y)[source]¶
Element-wise \(\log(e^x + e^y)\) function.
This function is useful in statistics where the calculated probabilities of events may be so small as to exceed the range of normal floating point numbers. In such cases the logarithm of the calculated probability is stored. This function allows adding probabilities stored in such a fashion.
- Parameters
x (
Tensor
) – input tensor. Should have a floating-point data type.y (
Tensor
) – input tensor. Must be compatible with \(x\) (see Broadcasting mechanism and rules ). Should have a floating-point data type.
- Return type
- Returns
a tensor containing the evaluated result for each element in \(x\) and \(y\). The returned tensor must have a floating-point data type determined by Type promotion rules.
Examples
>>> prob1 = F.log(1e-10) >>> prob2 = F.log(2e-10) >>> F.logaddexp(prob1, prob2) Tensor(-21.927238, device=xpux:0)