15/42
Part 3 of 6 · The worked exampleLearn

view and transpose keep each row one position

Now split it the right way.

print(q.view(B, T, H, d).transpose(1, 2))
tensor([[[[ 0,  1],
          [10, 11],
          [20, 21]],

         [[ 2,  3],
          [12, 13],
          [22, 23]]]])

Laid side by side:

The split on twelve numbersInteractive
head 0
token 001token 11011token 22021
head 1
2312132223
transpose(1, 2) puts the heads first. Each head is now its own small grid with one row per token: every row has a single tens digit.

Row tt of each head is position tt, and each head holds its own two channels of it.