clip

ivy.clip(x: ivy.NativeArray, x_min: Union[numbers.Number, ivy.NativeArray], x_max: Union[numbers.Number, ivy.NativeArray], f: Optional[ivy.Framework] = None) → ivy.NativeArray[source]

Clips (limits) the values in an array.

Given an interval, values outside the interval are clipped to the interval edges (element-wise). For example, if an interval of [0, 1] is specified, values smaller than 0 become 0, and values larger than 1 become 1.

Parameters
  • x (array) – Input array containing elements to clip.

  • x_min (scalar or array) – Minimum value.

  • x_max (scalar or array) – Maximum value.

  • f (ml_framework, optional) – Machine learning framework. Inferred from inputs if None.

Returns

An array with the elements of x, but where values < x_min are replaced with x_min, and those > x_max with x_max.


Supported Frameworks:

empty jax_logo empty tf_logo empty pytorch_logo empty mxnet_logo empty numpy_logo empty