Does the scipy's logsumexp()
implementation include the hack that prevents underflow by subtracting the maximum found value in the array from each element?
The one explained here below, where m = maxval
:
Returns the log of summed exponentials of each row of the input tensor in the given dimension dim . The computation is numerically stabilized.
Compute the log of the sum of exponentials of input elements. Input array. Axis or axes over which the sum is taken.
You can inspect the source code defining logsumexp
here. (Note that there is a link to the source on the doc page).
You'll see:
a_max = a.max(axis=0)
...
out = log(sum(exp(a - a_max), axis=0))
So yes, scipy's logsumexp
is subtracting the maximum from each element.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With