Permute the dimensions of this tensor.

tch_permute(x, dims)

Arguments

x

tensor object

dims

the desired ordering of dimensions (0 based).

Examples

x <- tensor(array(1:10, dim = c(2,5,1))) x
#> tensor #> (1,.,.) = #> 1 #> 3 #> 5 #> 7 #> 9 #> #> (2,.,.) = #> 2 #> 4 #> 6 #> 8 #> 10 #> [ Variable[CPUIntType]{2,5,1} ]
tch_permute(x, c(2,1,0))
#> tensor #> (1,.,.) = #> 1 2 #> 3 4 #> 5 6 #> 7 8 #> 9 10 #> [ Variable[CPUIntType]{1,5,2} ]