import numpy as np#Syntax:numpy.sum(a, axis=None, dtype=None, out=None, keepdims=)
计算中所有元素的值
Example:
a = [1,2]print np.sum(a)#3a = np.matrix('1,2;3,4')print np.sum(a)#10print np.sum(a, axis=0)#[4, 6]print np.sum(a, axis = 1)#[3, 7]
本文共 307 字,大约阅读时间需要 1 分钟。
import numpy as np#Syntax:numpy.sum(a, axis=None, dtype=None, out=None, keepdims=)
计算中所有元素的值
Example:
a = [1,2]print np.sum(a)#3a = np.matrix('1,2;3,4')print np.sum(a)#10print np.sum(a, axis=0)#[4, 6]print np.sum(a, axis = 1)#[3, 7]
转载于:https://www.cnblogs.com/KennyRom/p/6607645.html