快捷方式

torch.rot90

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

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

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

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

  • dims (列表元組) – 旋轉軸。預設值為 [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 的完整開發者文件

檢視文件

教程

獲取適合初學者和高階開發者的深入教程

檢視教程

資源

查詢開發資源並獲得問題的解答

檢視資源