A transformer has no recurrence, so it needs another way to know word order. The paper adds fixed sine and cosine waves of different frequencies to the embeddings. Each position gets a unique pattern, and the model can learn to attend by relative offset.
Implement sinusoidal_positional_encoding(T, d), which returns the (T, d) table of sines and cosines.
d is even.Build the angle matrix pos / 10000^(2i/d), then fill even columns with sin and odd columns with cos.
No results yet
Run your code to check it against the examples, or submit to run every test.