flip¶
dragon.vm.torch.
flip
(
input,
dims
)[source]¶Reverse elements along the given dimension.
dims
could be negative:x = torch.tensor([[1, 2, 3], [4, 5, 6]]) # A negative dimension is the last-k dimension print(torch.flip(x, dims=1)) # [[3, 2, 1], [6, 5, 4]] print(torch.flip(x, dims=-1)) # Equivalent # Also, dimension could be a sequence of integers print(torch.flip(x, dims=(0, 1))) # [[6, 5, 4], [3, 2, 1]]
- Parameters:
- input (dragon.vm.torch.Tensor) – The input tensor.
- dims (Union[int, Sequence[int]]) – The dimension to reverse.
- Returns:
dragon.vm.torch.Tensor – The output tensor.