Generate the sinusoidal positional encodings of the original Transformer for n positions and model dimension dim. Even columns hold sin(pos⋅rk) and odd columns hold cos(pos⋅rk), where rk=10000−2⌊k/2⌋/dim for column k.
Implement solve(n,dim).
Returns. Return a float array of shape (n, dim).
Example 1
Input:
solve(3, 4)
Output:
[[0.0, 1.0, 0.0, 1.0], [0.841471, 0.540302, 0.01, 0.99995], [0.909297, -0.416147, 0.019999, 0.9998]]
Example 2
Input:
solve(1, 5)
Output:
[[0.0, 1.0, 0.0, 1.0, 0.0]]
No results yet
Run your code to check it against the examples, or submit to run every test.