torch.fliplr¶
- torch.fliplr(input) Tensor ¶
在左右方向翻转张量,返回一个新张量。
在左右方向翻转每行中的条目。列被保留,但以与之前不同的顺序出现。
注意
要求张量至少是 2 维的。
注意
torch.fliplr 制作了
input
数据的一个副本。这与 NumPy 的 np.fliplr 不同,后者在恒定时间内返回视图。由于复制张量的数据比查看数据需要更多的工作,因此 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]])