python numpy.power()函数的用法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lens___/article/details/84203105

numpy.power()用于数组元素求n次方

numpy.power(x1, x2) :x2可以是数字,也可以是数组,但是x1和x2的列数要相同

import numpy as np
x1 = range(7)
x1
Out[1]: range(0, 7)

np.power(x1,2)
Out[2]: array([ 0,  1,  4,  9, 16, 25, 36], dtype=int32)
x2 = range(1,8)

np.power(x1,x2)
Out[3]: array([     0,      1,      8,     81,   1024,  15625, 279936], dtype=int32)

猜你喜欢

转载自blog.csdn.net/lens___/article/details/84203105