We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
请教relative_transformer.py中_transpose_shift函数中的几个问题: (1)它实现了矩阵的什么变换(如移动、旋转等)? (2)怎么理解它是如何实现这种变换的呢? (3)倒数第3行中的indice为什么只选取奇数行呢? (4)_transpose_shift函数与_shift有什么区别,又有什么联系? 十分感谢
def _transpose_shift(self, E): #E=[B,N,L,2*L]=[bsz, head, max_len, 2max_len] 如[2, 4, 68, 136]; bsz, n_head, max_len, _ = E.size() zero_pad = E.new_zeros(bsz, n_head, max_len, 1) E = torch.cat([E, zero_pad], dim=-1).view(bsz, n_head, -1, max_len) # [B,N,2L,L] indice = (torch.arange(max_len) * 2 + 1).to(E.device) # 选取是奇数行:[1,3,5...135] E = E.index_select(index=indice, dim=-2).transpose(-1, -2) return E
The text was updated successfully, but these errors were encountered:
在对应函数的开头,我们都放置了一个例子,你可以对照着看看。
TENER/modules/relative_transformer.py
Line 164 in d2614d5
Sorry, something went wrong.
No branches or pull requests
请教relative_transformer.py中_transpose_shift函数中的几个问题:
(1)它实现了矩阵的什么变换(如移动、旋转等)?
(2)怎么理解它是如何实现这种变换的呢?
(3)倒数第3行中的indice为什么只选取奇数行呢?
(4)_transpose_shift函数与_shift有什么区别,又有什么联系?
十分感谢
The text was updated successfully, but these errors were encountered: