Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在张量列表中查找最大绝对标量值_Python_Tensorflow - Fatal编程技术网

Python 在张量列表中查找最大绝对标量值

Python 在张量列表中查找最大绝对标量值,python,tensorflow,Python,Tensorflow,我有一个不同维度的张量列表。我想找到所有张量的最大绝对标量值。问题是,我想我需要一种方法来计算大于或小于张量,但我只能找到tf.equal()。这就是我想做的事情: curMaxAbs = tf.Variable(-1, tf.float64) for g in myList: maxG = tf.abs(tf.reduce_max(g)) minG = tf.abs(tf.reduce_min(g)) maxAbsG = maxG if tf.greaterThan(m

我有一个不同维度的张量列表。我想找到所有张量的最大绝对标量值。问题是,我想我需要一种方法来计算大于或小于张量,但我只能找到
tf.equal()
。这就是我想做的事情:

curMaxAbs = tf.Variable(-1, tf.float64)
for g in myList:
    maxG = tf.abs(tf.reduce_max(g))
    minG = tf.abs(tf.reduce_min(g))
    maxAbsG = maxG if tf.greaterThan(maxG,minG) else minG
    curMaxAbs = maxAbsG if tf.greaterThan(maxAbsG, curMaxAbs) else curMaxAbs
当然,似乎没有
tf.greaterThan()
函数。显然,如果我可以使用
tf.eval()
并将其转换为numpy数组,这将是微不足道的,但不幸的是,我需要在构建过程中执行此操作。

这样如何:

maxAbsG = tf.maximum ( maxG, minG )