[英]In Tensorflow, how can I select the minimum tensor among a few tensors?
根據Tensorflow API,我知道我可以沿着特定的軸reduce_min或reduce_max。 我還可以如下選擇兩個張量中的最小張量。
min = tf.minimum(x, y)
但是,我想知道如何在一組張量中選擇最小張量。 是否有張量中的最小值或最大值之類的函數?
非常感謝!
您可以stack
所有張量,然后使用reduce_min
a = tf.constant([3])
b = tf.constant([2])
c = tf.constant([1])
with tf.Session() as sess:
print(tf.reduce_min(tf.stack([a,b,c]),0).eval())
#[1]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.