Python numpy.exp() 到底做了什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31951980/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What exactly does numpy.exp() do?
提问by bugsyb
I'm very confused as to what np.exp() actually does. In the documentation it says that it: "Calculates the exponential of all elements in the input array." I'm confused as to what exactly this means. Could someone give me more information to what it actually does?
我对 np.exp() 的实际作用感到非常困惑。在文档中它说:“计算输入数组中所有元素的指数。” 我很困惑这到底是什么意思。有人能给我更多关于它实际作用的信息吗?
回答by Tom
It calculates exfor each xin your list where eis Euler's number (approximately 2.718). In other words, np.exp(range(5))
is similar to [math.e**x for x in range(5)]
.
它为列表中的每个x计算e x,其中e是欧拉数(约 2.718)。换句话说,类似于。np.exp(range(5))
[math.e**x for x in range(5)]
回答by machine yearning
The exponential function is e^x
where e
is a mathematical constant called Euler's number, approximately 2.718281
. This value has a close mathematical relationship with pi
and the slope of the curve e^x
is equal to its value at every point. np.exp()
calculates e^x
for each value of x
in your input array.
指数函数是e^x
其中e
是一个称为欧拉数的数学常数,大约为2.718281
。该值具有密切的数学关系,pi
曲线的斜率e^x
在每一点都等于其值。np.exp()
计算输入数组中的e^x
每个值x
。
回答by Arijit
exp(x) = e^x where e= 2.718281(approx)
exp(x) = e^x 其中 e= 2.718281(approx)
import numpy as np
ar=np.array([1,2,3])
ar=np.exp(ar)
print ar
output of the Sample Code-> [ 2 7 20]
示例代码的输出-> [ 2 7 20]