本文簡要介紹 python 語言中 numpy.moveaxis
的用法。
用法:
numpy.moveaxis(a, source, destination)
將數組的軸移動到新位置。
其他軸保持原來的順序。
- a: np.ndarray
軸應重新排序的數組。
- source: int 或 int 的序列
要移動的軸的原始位置。這些必須是唯一的。
- destination: int 或 int 的序列
每個原始軸的目標位置。這些也必須是唯一的。
- result: np.ndarray
帶有移動軸的數組。該數組是輸入數組的視圖。
參數:
返回:
例子:
>>> x = np.zeros((3, 4, 5)) >>> np.moveaxis(x, 0, -1).shape (4, 5, 3) >>> np.moveaxis(x, -1, 0).shape (5, 3, 4)
這些都達到了相同的結果:
>>> np.transpose(x).shape (5, 4, 3) >>> np.swapaxes(x, 0, -1).shape (5, 4, 3) >>> np.moveaxis(x, [0, 1], [-1, -2]).shape (5, 4, 3) >>> np.moveaxis(x, [0, 1, 2], [-1, -2, -3]).shape (5, 4, 3)
相關用法
- Python numpy mod用法及代碼示例
- Python numpy modf用法及代碼示例
- Python numpy ma.indices用法及代碼示例
- Python numpy matrix.A1用法及代碼示例
- Python numpy ma.zeros用法及代碼示例
- Python numpy matrix.T用法及代碼示例
- Python numpy matrix.I用法及代碼示例
- Python numpy ma.diff用法及代碼示例
- Python numpy mat用法及代碼示例
- Python numpy ma.mask_rowcols用法及代碼示例
- Python numpy ma.where用法及代碼示例
- Python numpy ma.zeros_like用法及代碼示例
- Python numpy mgrid用法及代碼示例
- Python numpy ma.notmasked_contiguous用法及代碼示例
- Python numpy ma.concatenate用法及代碼示例
- Python numpy ma.apply_along_axis用法及代碼示例
- Python numpy matrix.partition用法及代碼示例
- Python numpy ma.compress_rowcols用法及代碼示例
- Python numpy matrix.transpose用法及代碼示例
- Python numpy ma.vstack用法及代碼示例
- Python numpy ma.atleast_3d用法及代碼示例
- Python numpy ma.count用法及代碼示例
- Python numpy matrix.itemsize用法及代碼示例
- Python numpy ma.fix_invalid用法及代碼示例
- Python numpy ma.mean用法及代碼示例
注:本文由純淨天空篩選整理自numpy.org大神的英文原創作品 numpy.moveaxis。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。