Deal with overflow in exp using numpy

前端 未结 6 1918
你的背包
你的背包 2020-11-29 07:24

Using numpy, I have this definition of a function:

def powellBadlyScaled(X):
    f1 = 10**4 * X[0] * X[1] - 1
    f2 = numpy.exp(-numpy.float(X[0])) + numpy         


        
6条回答
  •  无人及你
    2020-11-29 07:55

    You can use numpy.seterr to control how numpy behaves in this circumstance: http://docs.scipy.org/doc/numpy/reference/generated/numpy.seterr.html

    You can also use the warnings module to control how warnings are or are not presented: http://docs.python.org/library/warnings.html

提交回复
热议问题