What does the following error:
Warning: overflow encountered in exp
in scipy/numpy using Python generally mean? I’m computing a ratio in log form, i.e. log(a) + log(b) and then taking the exponent of the result, using exp, and using a sum with logsumexp, as follows:
c = log(a) + log(b)
c = c - logsumexp(c)
some values in the array b are intentionally set to 0. Their log will be -Inf.
What could be the cause of this warning? thanks.
In your case, it means that
bis very small somewhere in your array, and you’re getting a number (a/borexp(log(a) - log(b))) that is too large for whatever dtype (float32, float64, etc) the array you’re using to store the output is.Numpy can be configured to
See
numpy.seterrto control how it handles having under/overflows, etc in floating point arrays.