torch.swapaxes
function swapaxes<S extends Shape, D0 extends number, D1 extends number>(input: Tensor<S>, dim0: D0, dim1: D1): Tensor<TransposeDimsShapeChecked<S, D0, D1>>Swaps two dimensions of the input tensor.
Parameters
inputTensor<S>- The input tensor
dim0D0- The first dimension to swap
dim1D1- The second dimension to swap
Returns
Tensor<TransposeDimsShapeChecked<S, D0, D1>>– Tensor with dimensions dim0 and dim1 swappedExamples
const x = torch.randn(2, 3, 4);
torch.swapaxes(x, 0, 2).shape; // [4, 3, 2]