Home / Maths for AI / Symbols / Vectors and matrices

Transpose

Say it: "A transpose"

What it means

Swap rows and columns: (A⊤)ij=Aji(A^\top)_{ij} = A_{ji}. An m×nm \times n matrix becomes n×mn \times m. Also written ATA^T or A′A'.

Example

(123456)⊤=(142536)\begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{pmatrix}^\top = \begin{pmatrix} 1 & 4 \\ 2 & 5 \\ 3 & 6 \end{pmatrix}

Rows become columns.

In code

import numpy as np
A = np.array([[1, 2, 3], [4, 5, 6]])
print(A.T)

Output

[[1 4]
 [2 5]
 [3 6]]

Where it appears in machine learning

a⊤b\mathbf{a}^\top \mathbf{b} is the dot product; attention computes QK⊤QK^\top.

Related symbols

Learn it properly in the free lesson Matrices, with practice questions that check your answers.