最佳答案
我写了以下剧本:
import numpy
d = numpy.array([[1089, 1093]])
e = numpy.array([[1000, 4443]])
answer = numpy.exp(-3 * d)
answer1 = numpy.exp(-3 * e)
res = answer.sum()/answer1.sum()
print res
但是我得到了这个结果,错误发生了:
nan
C:\Users\Desktop\test.py:16: RuntimeWarning: invalid value encountered in double_scalars
res = answer.sum()/answer1.sum()
似乎是输入元素太小了,以至于 python 把它们变成了零,但事实上除法有它的结果。
如何解决这类问题?