np.flip

Reverse the order of elements in an array along the given axis.

The shape of the array is preserved, but the elements are reordered.

沿着指定的轴反转元素

>>> A = np.arange(8).reshape((2,2,2))
>>> A
array([[[0, 1],
        [2, 3]],
       [[4, 5],
        [6, 7]]])
        
>>> flip(A, 0)
array([[[4, 5],
        [6, 7]],
       [[0, 1],
        [2, 3]]])
        
>>> flip(A, 1)
array([[[2, 3],
        [0, 1]],
       [[6, 7],
        [4, 5]]])

>>>np.flip(A, 2)
array([[[1, 0],
        [3, 2]],
       [[5, 4],
        [7, 6]]])

维度是从外到内,最外是0,最内是2

你可能感兴趣的:(python基础)