Loading

Numpy轴的概念

numpy中轴的概念是可以认为是数组的维度的概念

a = np.arange(24).reshape(2,3,4)
a
array([[[ 0,  1,  2,  3],
        [ 4,  5,  6,  7],
        [ 8,  9, 10, 11]],

       [[12, 13, 14, 15],
        [16, 17, 18, 19],
        [20, 21, 22, 23]]])
np.max(a,axis=0)
array([[12, 13, 14, 15],
       [16, 17, 18, 19],
       [20, 21, 22, 23]])
np.max(a,axis=1)
array([[ 8,  9, 10, 11],
       [20, 21, 22, 23]])
np.max(a,axis=2)
array([[ 3,  7, 11],
       [15, 19, 23]])
posted @ 2021-03-26 16:53  克豪  阅读(286)  评论(0)    收藏  举报