Head h meets only its own d columns of proj.weight. nn.Linear stores its weight out by in. The paper writes WO in by out, so there the same block is d rows.
Concat(head0,…,headH−1)WO=h=0∑H−1headhWO(h)
Here WO(h) is the block of d rows of WO that lines up with head h. So each head writes into the output through its own slice of WO, and the layer adds the contributions up.
The tests apply m.proj in the reference math, so leaving it out fails them.
In the editor, finish forward(x). split_heads, merge_heads and __init__ from the earlier tasks are in the file, and it prints the output's shape.
Pick an answer above to see the rest
Instructions
1
Finish forward(x): self.qkv, split into heads, scores over the square root of d, the mask, a softmax over the keys, then the values.
2
Merge the heads and apply self.proj. split_heads, merge_heads and __init__ are already there.