捷徑

torch.rot90

torch.rot90(input, k=1, dims=(0, 1)) Tensor

在由 dims 軸指定的平面上,將 n 維張量旋轉 90 度。如果 k > 0,則旋轉方向是從第一個軸朝向第二個軸;如果 k < 0,則從第二個軸朝向第一個軸。

參數
  • input (Tensor) – 輸入張量。

  • k (int) – 旋轉次數。預設值為 1。

  • dims (list tuple) – 要旋轉的軸。預設值為 [0, 1]。

範例

>>> x = torch.arange(4).view(2, 2)
>>> x
tensor([[0, 1],
        [2, 3]])
>>> torch.rot90(x, 1, [0, 1])
tensor([[1, 3],
        [0, 2]])

>>> x = torch.arange(8).view(2, 2, 2)
>>> x
tensor([[[0, 1],
         [2, 3]],

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

        [[5, 7],
         [4, 6]]])

文件

存取 PyTorch 的完整開發人員文件

檢視文件

教學課程

取得適用於初學者和進階開發人員的深入教學課程

檢視教學課程

資源

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

檢視資源