理解维度问题,记忆右边图片坐标的0,1,2,
就记住了计算方向问题,每个矩阵想象一张图片,多个图片叠加,
哪个维度做,哪个维度就被降维度1,默认无
所以 (4,3,2)
axis =0 ,就变成3,2
axis=1, 变成4,2
axis=2, 就变成 4,3
>>> import numpy as np
>>> z = np.arange(24).reshape(2,3,4)
>>> z
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(z,axis=0)
array([[12, 13, 14, 15],
[16, 17, 18, 19],
[20, 21, 22, 23]])
>>> np.max(z,axis=1)
array([[ 8, 9, 10, 11],
[20, 21, 22, 23]])
>>> np.max(z,axis=2)
array([[ 3, 7, 11],
[15, 19, 23]])