numpy axis in the meaning and use

numpy axis represents the shaft means, the (e.g., sum, exp) values ​​of certain functions in different axis, different calculation, use and do not understand the meaning of the axis, can not be used to process data numpy good.
Explain axis by example meanings:
arrs = np.arange(24).reshape((3,2,4))
print arrs
print np.sum(arrs, axis=0)
print  np.sum(arrs, axis=1)
print np.sum(arrs, axis=2) 

 

Following array
Is a dimension of 3 × 2 × 4, the red line drawing data expressed as:
        a[0][0][0] = 0,  
        a[1][0][0] = 8, 
        a[2][0][0] = 16
 
        When = 0 axis, and the vertical axis represents the use of which np.sum (darrs, axis = 0) during operation of a [0] [0] [0] + a [1] [0] [0] + a [2 ] [0] [0]
        
 
 

Guess you like

Origin www.cnblogs.com/HankCui/p/11288907.html