padded_stack#
- pytorch_forecasting.utils._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 of torch.Tensor) – List of tensors to stack.
side (str, optional) – Side on which to pad - “left” or “right”. Defaults to “right”.
mode (str, optional) – ‘constant’, ‘reflect’, ‘replicate’ or ‘circular’. Defaults to ‘constant’.
value (int or float, optional) – Value to use for constant padding. Defaults to 0.
- Returns:
Stacked tensor.
- Return type:
torch.Tensor