Skip to content Skip to sidebar Skip to footer

TensorFlow Function To Check Whether A Value Is In Given Range?

I know there is tf.greater(x,y) which will return true if x > y (element-wise). Is there a function that returns true if lower_bound < x < upper_bound (element-wise) for a

Solution 1:

There's not a specific function for that, but you can use a combination of tf.greater, tf.less, and tf.logical_and to get the same result.

lower_tensor = tf.greater(x, lower)
upper_tensor = tf.less(x, upper)
in_range = tf.logical_and(lower_tensor, upper_tensor)

Post a Comment for "TensorFlow Function To Check Whether A Value Is In Given Range?"