简体   繁体   English

TensorFlow布尔Tensor操作等效项

[英]TensorFlow Boolean Tensor Operations Equivalents

I am looking for TensorFlow equivalents to the following Numpy operations 我正在寻找与以下Numpy操作等效的TensorFlow

Comparison 比较方式

  • allclose(a, b[, rtol, atol, equal_nan]) Returns True if two arrays are element-wise equal within a tolerance. allclose(a, b[, rtol, atol, equal_nan])如果两个数组在公差范围内按元素方式相等,则返回True
  • isclose(a, b[, rtol, atol, equal_nan]) Returns a boolean array where two arrays are element-wise equal within a tolerance. isclose(a, b[, rtol, atol, equal_nan])返回一个布尔数组,其中两个数组在公差范围内在元素方面相等。
  • all(a[, axis, out, keepdims]) Test whether all array elements along a given axis evaluate to True . all(a[, axis, out, keepdims])测试是否沿着给定轴的所有数组元素求值为True
  • any(a[, axis, out, keepdims]) Test whether any array element along a given axis evaluates to True . any(a[, axis, out, keepdims])测试沿给定轴的任何数组元素的求值是否为True

Unfortunately, there are no ops that do exactly the same thing for allclose or isclose , but you can have workarounds. 不幸的是,没有任何操作对allcloseisclose做完全相同的事情,但是您可以有一些解决方法。

isclose : combine tf.abs , tf.sub , tf.less or tf.less_equal . isclose :组合tf.abstf.subtf.lesstf.less_equal

allclose : based on isclose, use tf.reduce_all in addition allclose :基于isclose,另外使用tf.reduce_all

all : use tf.reduce_all all :使用tf.reduce_all

any : use tf.reduce_any any :使用tf.reduce_any

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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