[英]Find maximum absolute scalar value in list of tensors
I have a list of tensors, with different dimensions. 我有张量的列表,尺寸不同。 I want to find the maximum absolute scalar value of all the tensors.
我想找到所有张量的最大绝对标量值。 Trouble is, I think I need a way to do greater than or less than on tensors, but I can only find
tf.equal()
. 麻烦的是,我想我需要一种大于或小于张量的方法,但是我只能找到
tf.equal()
。 This is the kind of thing I'd like to do: 这是我想做的事情:
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
Of course there doesn't seem to be a tf.greaterThan()
function. 当然,似乎没有
tf.greaterThan()
函数。 Obviously this would be trivial if I could use tf.eval()
and convert to numpy arrays but unfortunately I need to do this during construction. 显然,如果我可以使用
tf.eval()
并转换为numpy数组,这将是微不足道的,但是不幸的是,我需要在构造过程中执行此操作。
像这样的tf.maximum
怎么样:
maxAbsG = tf.maximum ( maxG, minG )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.