ivy.clip(x, x_min, x_max, f=None)[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.

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

  • x_min (scalar) – Minimum value.

  • x_max (scalar) – Maximum value.

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


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