numpy.sum()
中有一个名为keepdims
的参数,它是什么作用?
您可以在此处文档中看到:http://docs.scipy.org/doc/numpy/reference/generated/numpy.sum.html
numpy.sum(a, axis=None, dtype=None, out=None, keepdims=False)[source]
Sum of array elements over a given axis.
Parameters:
...
keepdims : bool, optional
If this is set to True, the axes which are reduced are left in the result as
dimensions with size one. With this option, the result will broadcast
correctly against the input array.
...
sum
函数的作用,那么这个参数就会更有意义。您是否熟悉结果的形状如何取决于输入数组和轴选择? - hpaulj