-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Begin to add Contextual positional encoding
- Loading branch information
1 parent
b880622
commit 06232dc
Showing
2 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from zipformer import ContextualPositionalEncoding | ||
|
||
|
||
def test(): | ||
embed_dim = 5 | ||
npos_max = 10 | ||
cope = ContextualPositionalEncoding(embed_dim=embed_dim, npos_max=npos_max) | ||
q = torch.rand(2, 3, 4, embed_dim) | ||
qk = torch.rand(2, 3, 4, 6) | ||
|
||
p = cope(q=q, qk=qk) | ||
print(p.shape) | ||
|
||
|
||
def main(): | ||
test() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters