【发布时间】:2023-02-06 20:13:48
【问题描述】:
很抱歉问了这么一个微不足道的问题,但我是 Tensorflow 的新手。 我有两个张量。 y_true = [[1,0], [0,1], [1,0], [1,0], [0,1], [0,1], [1,0], [0,1] , [1,0], [0,1]] y_pred = [[0.6,0.4], [0.3,0.7], [0.8,0.2], [0.8,0.2], [0.3,0.7],[0.1,0.9],[0.9, 0.1],[0.4,0.6] ,[0.6,0.4],[0.2,0.8]] 此外,我想根据每个 [1,0] 或 [0,1] 值过滤 y_true 。
我有以下概念,我认为它不是很有效。例如,在 [0,1] 上过滤 y_true 时:
ind_zero = tf.math.equal(y_true,[1,0])
index_zero = tf.math.logical_and(ind_zero[:,0],ind_zero[:,1])
zeros = tf.gather_nd(y_pred,tf.where(index_zero))
是否存在另一种更有效的想法? 提前致谢。
【问题讨论】:
标签: tensorflow