关于:
numpy.flip(数组,轴):沿指定的轴反转数组元素的顺序,从而保留数组的形状。
参数:
array : [array_like]Array to be input axis : [integer]axis along which array is reversed.
返回值:
reversed array with shape preserved
# Python Program illustrating
# numpy.flip() method
import numpy as geek
array = geek.arange(8).reshape((2,2,2))
print("Original array : \n", array)
print("Flipped array : \n", geek.flip(array, 0))
输出:
Original array : [[[0 1] [2 3]] [[4 5] [6 7]]] Flipped array : [[[4, 5] [6, 7]] [[0, 1] [2, 3]]]
参考文献:
https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.flip.html#numpy.flip
相关用法
注:本文由纯净天空筛选整理自 numpy.flip() in Python。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。