rescale

rescale(data: Tensor, resmin: int | float | Tensor | None, resmax: int | float | Tensor | None, *, srcmin: int | float | Tensor | None = None, srcmax: int | float | Tensor | None = None, dim: int | tuple[int, ...] | None = None) Tensor[source]

Rescales a tensor (min-max normalization).

Parameters:
  • data (torch.Tensor) – tensor to rescale.

  • resmin (int | float | torch.Tensor | None) – minimum value for the tensor after rescaling, unchanged if None.

  • resmax (int | float | torch.Tensor | None) – maximum value for the tensor after rescaling, unchanged if None.

  • srcmin (int | float | torch.Tensor | None, optional) – minimum value for the tensor before rescaling, computed if None. Defaults to None.

  • srcmax (int | float | torch.Tensor | None, optional) – maximum value for the tensor before rescaling, computed if None. Defaults to None.

  • dim (int | tuple[int, ...] | None, optional) – dimension(s) along which amin/amax are computed if not provided, all dimensions if None. Defaults to None.

Returns:

rescaled tensor.

Return type:

torch.Tensor