clip_by_value

dragon.vm.tensorflow.clip_by_value(
  t,
  clip_value_min,
  clip_value_max,
  name=None
)[source]

Compute the clipped input according to the given bounds.

\[\text{out} = \min(\max(x, \text{low}), \text{high}) \]

Examples:

x = tf.constant([-2, -1, 0, 1, 2])
print(tf.clip_by_value(x, clip_value_min=0, clip_value_max=1))
Parameters:
  • t (dragon.Tensor) – The tensor \(x\).
  • clip_value_min (number, optional) – The value to \(\text{low}\).
  • clip_value_max (number, optional) – The value to \(\text{high}\).
  • name (str, optional) – The operation name.
Returns:

dragon.Tensor – The output tensor.