前言 使用numpy sum(a,axis=0)的时候,对axis参数比较费解,和直觉不太一样,故此记录 b = np.arange(12).reshape(3,4) b array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]]) b.sum(axis=0) array([12, 15, 18, 21]) b.sum(axis=1) array([ 6, 22, 38]) array([[ 0, 1, 3, 6], [ 4, 9, 15, 22]…