捷徑

torch.swapaxes

torch.swapaxes(input, axis0, axis1) Tensor

torch.transpose() 的別名。

此函數等同於 NumPy 的 swapaxes 函數。

範例

>>> x = torch.tensor([[[0,1],[2,3]],[[4,5],[6,7]]])
>>> x
tensor([[[0, 1],
        [2, 3]],

        [[4, 5],
        [6, 7]]])
>>> torch.swapaxes(x, 0, 1)
tensor([[[0, 1],
        [4, 5]],

        [[2, 3],
        [6, 7]]])
>>> torch.swapaxes(x, 0, 2)
tensor([[[0, 4],
        [2, 6]],

        [[1, 5],
        [3, 7]]])

文件

取得 PyTorch 的完整開發者文件

檢視文件

教學

取得針對初學者和進階開發者的深入教學

檢視教學

資源

尋找開發資源並獲得解答

檢視資源