torch.fliplr¶
- torch.fliplr(input) Tensor¶
沿左右方向翻轉 Tensor,返回一個新的 Tensor。
沿左右方向翻轉每一行中的元素。列得到保留,但順序與之前不同。
注意
要求 Tensor 至少是 2 維的。
注意
torch.fliplr 會複製
input的資料。這與 NumPy 的 np.fliplr 不同,後者在常數時間內返回檢視。由於複製 Tensor 資料比建立檢視更耗時,因此 torch.fliplr 預計會比 np.fliplr 慢。- 引數
input (Tensor) – 必須至少是 2 維的。
示例
>>> x = torch.arange(4).view(2, 2) >>> x tensor([[0, 1], [2, 3]]) >>> torch.fliplr(x) tensor([[1, 0], [3, 2]])