code for me : angle_rads = get_angles(np.arange(positions)[:, np.newaxis],
np.arange(d)[np.newaxis, :],
d)
# apply sin to even indices in the array; 2i
angle_rads[:, 0::2] = np.sin(angle_rads)
# apply cos to odd indices in the array; 2i+1
angle_rads[:, 1::2] = np.cos(angle_rads)
# END CODE HERE
Why are they not working please help me. I spent a long time but no results.
Hi, shouldn’t it be
angle_rads[:, 0::2] = np.sin(angle_rads[:, 0::2])
angle_rads[:, 1::2] = np.cos(angle_rads[:, 1::2])
instead?
Have you passed the exercise above it? exercise 1 get_angles?
I have the code:
angles = pos / np.power(10000, 2*i/d)
and it fails the tests… could you help me there? Thanks!
in positional_encoding_test(target)
24 trueAngs = get_angles(pos_m, dims, d_model)[:, 0::2] % (2 * np.pi)
25
—> 26 assert np.allclose(angs[0], trueAngs), “Did you apply sin and cos to even and odd parts respectively?”
27
28 print("\033[92mAll tests passed")
AssertionError: Did you apply sin and cos to even and odd parts respectively?