MCPcopy Create free account
hub / github.com/Anoise/WTFlib / ProbMask

Class ProbMask

LDPS_Graph/utils/masking.py:15–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13
14
15class ProbMask():
16 def __init__(self, B, H, L, index, scores, device="cpu"):
17 _mask = torch.ones(L, scores.shape[-1], dtype=torch.bool).to(device).triu(1)
18 _mask_ex = _mask[None, None, :].expand(B, H, L, scores.shape[-1])
19 indicator = _mask_ex[torch.arange(B)[:, None, None],
20 torch.arange(H)[None, :, None],
21 index, :].to(device)
22 self._mask = indicator.view(scores.shape).to(device)
23
24 @property
25 def mask(self):
26 return self._mask
27
28
29class LocalMask():

Callers 1

_update_contextMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected