clip_by_value#

class usencrypt.ai.preprocessing.clip_by_value(input, clip_val_min, clip_val_max)#

Clips the input to values in the specified range.

Parameters
  • input (list or numpy.ndarray int, float, usencrypt.cipher.Int, or usencrypt.cipher.Float) – The input data to clip.

  • clip_val_min (int or float) – The minimum value to clip.

  • clip_val_max (int or float) – The maximum value to clip.

Returns

The clipped input array.

Return type

list or numpy.ndarray of int, float, usencrypt.cipher.Int, or usencrypt.cipher.Float

Examples
>>> import numpy as np
>>> import usencrypt as ue
>>> x = np.array([[-10., -1., 0.], [0., 2., 10.]])
>>> x
array([[-10.  -1.   0.]
       [  0.   2.  10.]])
>>> clipped = ue.ai.preprocessing.clip_by_value(x, clip_val_min=-1, clip_val_max=1)
>>> clipped
array([[-1. -1.  0.]
       [ 0.  1.  1.]])