原文:https://docs.scipy.org/doc/numpy/reference/generated/numpy.swapaxes.html
校对:(虚位以待)
numpy.
swapaxes
(a, axis1, axis2)[source]交换数组的两个轴。
参数: | a:array_like
axis1:int
axis2:int
|
---|---|
返回: | a_swapped:ndarray
|
例子
>>> x = np.array([[1,2,3]])
>>> np.swapaxes(x,0,1)
array([[1],
[2],
[3]])
>>> x = np.array([[[0,1],[2,3]],[[4,5],[6,7]]])
>>> x
array([[[0, 1],
[2, 3]],
[[4, 5],
[6, 7]]])
>>> np.swapaxes(x,0,2)
array([[[0, 4],
[2, 6]],
[[1, 5],
[3, 7]]])