gpt4 book ai didi

python - 如何选择张量中的一组项目

转载 作者:行者123 更新时间:2023-12-01 02:25:08 24 4
gpt4 key购买 nike

在 tensorflow 中。如何选择所有三元组 (x, y, c),其中 c > 0.5

enter image description here

我知道这可能是一个非常基本的问题,但我对 Tensorflow 很陌生。

最佳答案

使用tf.where。例如,

x = np.random.rand(20,3)
sess = tf.Session()
print x[tf.where(tf.greater(x[:,2], 0.5)).eval(session=sess)]

或者稍微干净一点,tf.boolean_mask(x,tf.greater(x[:,2], 0.5)).eval(session=sess)

关于python - 如何选择张量中的一组项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47490476/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com