numpy.log()
它不是一个方法numpy.ndarray
,它是numpy
模块中的一个函数,所以你必须这样调用它:
In [1]: import numpy In [2]: x = numpy.random.rand(3,3) In [3]: x Out[3]: array([[ 0.05047638, 0.40156621, 0.29631731], [ 0.21764918, 0.49813348, 0.48520004], [ 0.59433129, 0.53859086, 0.66388153]]) In [4]: numpy.log(x) Out[4]: array([[-2.98624972, -0.91238286, -1.21632442], [-1.52487076, -0.69688721, -0.72319401], [-0.52031839, -0.61879907, -0.40965157]])