To compute position encoding vectors, in the assignment:
- We initialize a matrix of all possible values for the sine and cosine functions:
N = get_angels(...)
.The matrix
N
has dimensionalitypos x i
. Wherepos
is a position (or time step) andi
refers to a different dimension of the position encoding (e.g.i = {1,2,...,n}
). - Later we use values in the matrix
N
to calculate actual values for each position encoding passing values fromN
as arguments to sine and cosine functions.Each row of the matrix
N
provides values required to calculate a position encoding for the positionpos
.The value of the position encoding vector at index
i
correspond to a point on the sinusoid curve for odd indicesi in {1,3,5,...}
and a point on the matched cosine curve for even indicesi in {2,4,6,...}
.
@shubhamchhetri I hope this makes things clear.