fn
movedim
→Tensormovedim(input: Tensor, source: int | Sequence[int], destination: int | Sequence[int])Move one or more dimensions to new positions.
The remaining dims keep their relative order. Equivalent to
permute with an automatically computed permutation but easier
to read when only a few axes change.
Parameters
inputTensorSource tensor.
sourceint or sequence of intOriginal dimension positions.
destinationint or sequence of intTarget dimension positions (must have the same length as
source).Returns
TensorView with rearranged strides.
Notes
Common use: convert between channel-first (N, C, H, W) and
channel-last (N, H, W, C) by movedim(x, 1, -1).
Examples
>>> import lucid
>>> x = lucid.zeros(2, 3, 4, 5)
>>> lucid.movedim(x, 1, -1).shape
(2, 4, 5, 3)