TensorFlow function to check whether a value is in given range?

丶灬走出姿态 提交于 2021-02-10 12:14:30

问题


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 tensor x?


回答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)


来源:https://stackoverflow.com/questions/55870502/tensorflow-function-to-check-whether-a-value-is-in-given-range

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!