Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong positional encoding #38

Open
varshiths opened this issue Jun 21, 2018 · 2 comments
Open

Wrong positional encoding #38

varshiths opened this issue Jun 21, 2018 · 2 comments

Comments

@varshiths
Copy link

position_enc = np.array([
      [pos / np.power(10000, 2.*i/num_units) for i in range(num_units)]
      for pos in range(T)])

In the paper, section 3.5, the embedding (before the application of sine or cosine) for even positions in [0..num_units] indexed by 2*i is the same as that for odd positions.
The correct code should be

position_enc = np.array([
      [pos / np.power(10000, (i-i%2)/num_units) for i in range(num_units)]
      for pos in range(T)])
@imhuay
Copy link

imhuay commented Jul 20, 2018

You are right!

@LauJames
Copy link

Great ! This issue makes me have a deeper understanding of position embedding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants