python numpy.sum 参数axis,keepdims
keepdims主要用于保持矩阵的二维特性import numpy as npa = np.array([[1,2],[3,4]])# 按行相加,并且保持其二维特性print(np.sum(a, axis=1, keepdims=True))# 按行相加,不保持其二维特性print(np.sum(a, axis=1))输出array([[3], [7]])array([3, 7])...
原创
2018-05-02 15:20:51 ·
4388 阅读 ·
0 评论