tensorly.clip

clip(tensor, a_min=None, a_max=None)

Clip the values of a tensor to within an interval.

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

Not more than one of a_min and a_max may be None.

Parameters:

tensor : tl.tensor

The tensor.

a_min : scalar, optional

Minimum value. If None, clipping is not performed on lower bound.

a_max : scalar, optional

Maximum value. If None, clipping is not performed on upper bound.

Returns:

tensor