import tensorflow as tf;
A = [[0.8,0.6,0.3], [0.1,0.6,0.4]]
B = [1, 1]
out = tf.nn.in_top_k(A, B, 1)
with tf.Session() as sess:
sess.run(tf.initialize_all_variables())
print sess.run(out)
输出为[false true]'
理解因为k值为1就是说最大的一个概率索引是多少(分别是0,1)所以为[false true]
如果k=2那么就是(【0,1】,【1,2】)这是就该是[true true],因为两个的索引都包含了1
参考https://blog.csdn.net/uestc_c2_403/article/details/73187915和https://blog.csdn.net/Enchanted_ZhouH/article/details/77200592