Amazon-inspired sequence model needs deterministic position information without adding learned position parameters. You need to construct the sinusoidal positional encoding for the requested sequence length and embedding dimension.
Build the sinusoidal positional encoding matrix of shape (n, d): for position p and column c, with rc=10000−2⌊c/2⌋/d, even columns hold sin(prc) and odd columns hold cos(prc).
Implement solve(n,d).
Returns. Return a float NumPy array of shape (n, d).
Example 1
Input:
solve(2, 4)
Output:
[[0.0, 1.0, 0.0, 1.0], [0.841471, 0.540302, 0.01, 0.99995]]
Example 2
Input:
solve(3, 3)
Output:
[[0.0, 1.0, 0.0], [0.841471, 0.540302, 0.002154], [0.909297, -0.416147, 0.004309]]
No results yet
Run your code to check it against the examples, or submit to run every test.