fn
flip
→Tensorflip(input: Tensor, dims: int | Sequence[int])Reverse the order of elements along the specified dims.
Each listed dimension is reversed independently. Equivalent to
indexing with [::-1] along those axes but expressed as a single
op that returns a contiguous result.
Parameters
inputTensorSource tensor.
dimsint or sequence of intDimension(s) to reverse.
Returns
TensorTensor of the same shape as input with the listed dims
reversed.
Notes
Flipping is involutive: flip(flip(x, d), d) == x.
Examples
>>> import lucid
>>> x = lucid.tensor([[1, 2], [3, 4]])
>>> lucid.flip(x, dims=[0])
Tensor([[3, 4],
[1, 2]])