简体   繁体   中英

TensorFlow Boolean Tensor Operations Equivalents

I am looking for TensorFlow equivalents to the following Numpy operations

Comparison

  • allclose(a, b[, rtol, atol, equal_nan]) Returns True if two arrays are element-wise equal within a tolerance.
  • isclose(a, b[, rtol, atol, equal_nan]) Returns a boolean array where two arrays are element-wise equal within a tolerance.
  • all(a[, axis, out, keepdims]) Test whether all array elements along a given axis evaluate to True .
  • any(a[, axis, out, keepdims]) Test whether any array element along a given axis evaluates to True .

Unfortunately, there are no ops that do exactly the same thing for allclose or isclose , but you can have workarounds.

isclose : combine tf.abs , tf.sub , tf.less or tf.less_equal .

allclose : based on isclose, use tf.reduce_all in addition

all : use tf.reduce_all

any : use tf.reduce_any

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM