關於:
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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。