⊤^\top

Transpose

Read "A transpose". The raised T flips a matrix so its rows become its columns. On a vector it turns a column into a row.

Entry by entry, (A⊤)ij=Aji(A^\top)_{ij} = A_{ji}: the number in row ii, column jj of A⊤A^\top is the number in row jj, column ii of AA. A 3×53 \times 5 matrix becomes 5×35 \times 3.

In this course its main job is making shapes fit so a multiplication is allowed. QK⊤QK^\top works because QQ is N×dkN \times d_k and K⊤K^\top is dk×Md_k \times M, giving the N×MN \times M matrix of scores: one row per query, one column per key. In self-attention M=NM = N, so it is square. QKQK without the transpose would not be a valid product.

u⊤v\mathbf{u}^\top \mathbf{v} is the dot product written as a matrix product: a 1×d1 \times d row times a d×1d \times 1 column gives one number.

Example

[123456]⊤=[142536]\begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix}^\top = \begin{bmatrix} 1 & 4 \\ 2 & 5 \\ 3 & 6 \end{bmatrix}

The first row (1, 2, 3) becomes the first column. A 2×3 matrix becomes 3×2.

Where the course uses it

Related terms