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

Method __init__

LDPS_Graph/utils/masking.py:16–22  ·  view source on GitHub ↗
(self, B, H, L, index, scores, device="cpu")

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected