Movedim
movedim(input, source, destination) -> Tensor
Moves the dimension(s) of input at the position(s) in source
to the position(s) in destination.
Other dimensions of input that are not explicitly moved remain in
their original order and appear at the positions not specified in destination.
Examples
if (torch_is_installed()) {
t <- torch_randn(c(3,2,1))
t
torch_movedim(t, 2, 1)$shape
torch_movedim(t, 2, 1)
torch_movedim(t, c(2, 3), c(1, 2))$shape
torch_movedim(t, c(2, 3), c(1, 2))
}
#> torch_tensor
#> (1,.,.) = 
#>  -2.3277 -0.0853  0.0530
#> 
#> (2,.,.) = 
#>   0.8038  0.1844 -0.9463
#> [ CPUFloatType{2,1,3} ]