-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
sincos位置编码问题 #379
Comments
DeepCTR/deepctr/layers/sequence.py Lines 640 to 642 in 0df401c
这样就得到了公式里的 PE(pos, 2i)=sin(pos/10000^{2i/d}) PE(pos,2i+1)=cos(pos/10000^{2i/d}) 代码实现应该是和公式一样的吧 |
嗯嗯,多谢回复。pos / np.power(10000, 2. * i / num_units) 对应公式里的pos/10000^{2i/d},这句话没错,后面的奇偶数列取sin\cos也没错,问题在于np.array([ [pos / np.power(10000, 2. * i / num_units) for i in range(num_units)] for pos in range(T)]这句代码,得到的结果应该是 |
这里代码确实有问题,非常感谢您细致地排查问题,我们会在下个版本(v0.8.7)中对该问题进行修复,祝好! |
transformer的位置编码好像跟公式不一样?
position_enc = np.array([ [pos / np.power(10000, 2. * i / num_units) for i in range(num_units)] for pos in range(T)]
公式是PE(pos, 2i)=sin(pos/10000^{2i/d})
PE(pos,2i+1)=cos(pos/10000^{2i/d})
所以应该是np.power(10000, i // 2 * 2. / num_units) ???
The text was updated successfully, but these errors were encountered: