且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

python中scipy/numpy中的exp溢出了吗?

更新时间:2021-09-16 01:47:31

在您的情况下,这意味着b在数组中的某个地方非常小,并且您得到一个数字( a/bexp(log(a) - log(b)))对于您用于存储输出的数组的任何dtype(float32,float64等)都太大.

In your case, it means that b is very small somewhere in your array, and you're getting a number (a/b or exp(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可以配置为

Numpy can be configured to

  1. 忽略这些错误,
  2. 打印错误,但不发出警告以停止执行(默认)
  3. 记录错误,
  4. 提出警告
  5. 引发错误
  6. 调用用户定义的函数

请参见 numpy.seterr 以控制它的方式处理浮点数组中的下溢/上溢等.

See numpy.seterr to control how it handles having under/overflows, etc in floating point arrays.