How do you transpose tensors?

19.9k Views Asked by At

We transpose a matrix $A$ by replacing $A_{ij}$ with $A_{ji}$, for all $i$ and $j$.

However, in case $A$ has more than two dimensions (that is, it is a tensor), I don't know how to apply the transpose operation.

  1. If A has dimensions $3\times 3 \times 8$, then what will replace $A_{ijk}$?

  2. If $A$ has shape $3\times 3\times 8\times 8$, then what will replace $A_{ijkl}$?

2

There are 2 best solutions below

0
On BEST ANSWER

The operation of taking a transpose is closely related to the concept of symmetry. One paper that addresses this is http://www.iaeng.org/publication/WCE2010/WCE2010_pp1838-1841.pdf. I have been researching $2^m$ dimensional matrices where the indices are zeros and ones. The transpose is found by changing all zeros to ones and ones to zeros.

0
On

Here is an example for 3D array,

First decide if it's row major (e.g. C) or column major (e.g. Fortran).

For a C array A[n3][n2][n1], the fastest dimension is n1, and we can name this original sequence as 321.

Then we can say we want a 321 -> 132 transpose operation, which is to copy the array element A[i3][i2][i1] to B[i1][i3][i2].

Often we assume from fastest dimension to slowest dimension being 123, then we can call the above transpose operation as 231 (i.e., 123->231).