torchcurves.functional.clamp#

torchcurves.functional.clamp(x, scale=1, out_min=-1, out_max=1)#

Clamp values in a tensor to a specified range.

The function clamps the values of the input tensor x to be within the output range, after scaling by the scale factor, by the formula:

\[x_{\mathrm{norm}} = \min(\mathrm{out\_max}, \max(\mathrm{out\_min}, x / \mathrm{scale}))\]
Parameters:
  • x (Union[Tensor, Sequence[Union[int, float]]]) – Input tensor to be normalized.

  • scale (float) – Scale factor for normalization. (default=1)

  • out_min (float) – Lower bound of the output interval (default=-1)

  • out_max (float) – Upper bound of the output interval (default=1)

Return type:

Tensor

Returns:

Normalized tensor.