快捷方式

torch.swapdims

torch.swapdims(input, dim0, dim1) 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.swapdims(x, 0, 1)
tensor([[[0, 1],
        [4, 5]],

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

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

文件

存取 PyTorch 的完整開發者文件

檢視文件

教學

取得為初學者和進階開發者提供的深入教學

檢視教學

資源

尋找開發資源並取得問題解答

檢視資源