mirror of
https://github.com/wassname/seq2seq-time.git
synced 2026-08-07 11:28:34 +08:00
transformer process
This commit is contained in:
@@ -8,3 +8,7 @@ def to_numpy(x):
|
||||
if isinstance(x, torch.Tensor):
|
||||
x = x.cpu().detach().numpy()
|
||||
return x
|
||||
|
||||
def mask_upper_triangular(N, device):
|
||||
"""Causal attention."""
|
||||
return torch.triu(torch.ones(N, N), diagonal=1).to(device).bool()
|
||||
|
||||
Reference in New Issue
Block a user