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]])