padded_stack#

pytorch_forecasting.utils.padded_stack(tensors: List[Tensor], side: str = 'right', mode: str = 'constant', value: int | float = 0) Tensor[source]#

Stack tensors along first dimension and pad them along last dimension to ensure their size is equal.

Parameters:
  • tensors (List[torch.Tensor]) – list of tensors to stack

  • side (str) – side on which to pad - “left” or “right”. Defaults to “right”.

  • mode (str) – ‘constant’, ‘reflect’, ‘replicate’ or ‘circular’. Default: ‘constant’

  • value (Union[int, float]) – value to use for constant padding

Returns:

stacked tensor

Return type:

torch.Tensor