MCPcopy Create free account
hub / github.com/K-Quant/HiDy / padding_mask

Method padding_mask

application/SMP/utils/dataloader.py:100–108  ·  view source on GitHub ↗
(self, features, max_len=None)

Source from the content-addressed store, hash-verified

98 return outs + (self.index[slc], mask, )
99
100 def padding_mask(self, features, max_len=None):
101 # Stack and pad features and masks (convert 2D to 3D tensors, i.e. add batch dimension)
102 lengths = [X.shape[0] for X in features] # original sequence length for each time series
103 if max_len is None:
104 max_len = max(lengths)
105
106 padding_masks = self._padding_mask(torch.tensor(lengths, dtype=torch.int16, device=self.device), max_len=max_len)
107 # (batch_size, padded_length) boolean tensor, "1" means keep
108 return padding_masks
109
110 @staticmethod
111 def _padding_mask(lengths, max_len=None):

Callers 1

getMethod · 0.95

Calls 1

_padding_maskMethod · 0.95

Tested by

no test coverage detected