create_mask#

pytorch_forecasting.utils.create_mask(size: int, lengths: LongTensor, inverse: bool = False) BoolTensor[source]#

Create boolean masks of shape len(lenghts) x size.

An entry at (i, j) is True if lengths[i] > j.

Parameters
  • size (int) – size of second dimension

  • lengths (torch.LongTensor) – tensor of lengths

  • inverse (bool, optional) – If true, boolean mask is inverted. Defaults to False.

Returns

mask

Return type

torch.BoolTensor