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

2.2.1 PositionalEncoding类 #48

Open
momoyrz opened this issue Dec 29, 2023 · 0 comments
Open

2.2.1 PositionalEncoding类 #48

momoyrz opened this issue Dec 29, 2023 · 0 comments

Comments

@momoyrz
Copy link

momoyrz commented Dec 29, 2023

div_term = torch.exp(torch.arange(0, d_model, 2) * -(math.log(10000.0) / d_model))
计算分母的时候为什么先对数运算后指数运算,这样不麻烦吗?完全可以直接:
div_term = 1 / 10000 ** (torch.arange(0, d_model, 2) / d_model)

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

1 participant