You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having an issue with computing the accuracy of my model. I want to see if the top 5 predictions contains the actual label when comparing against the test set.
From what I've read in the documentation TensorFlow doesn't seem to have something like fetching the top 5 from activation and seeing if one of the items is contained in argmax(y,1)
I would suggest linking to the tf.nn.top_k function in the documentation right after argmin and argmax, potentially under the name of argsort (which is what Numpy users would search for).
Reacted by Colin Rofls, quilby, Tim Zaman, Clemens Rosenbaum, Raghavendra Kotikalapudi, Brans, Akshay.L.Aradhya, Bichen Wu, Dylan Paiton, Dragos and 2 more
I've just met this question and I've found one function that is exactly what I want.
tf.nn.in_top_k(predictions, targets, k, name=None)
Says whether the targets are in the top K predictions.
This outputs a batch_size bool array, an entry out[i] is true if the prediction for the target class is among the top k predictions among all predictions for example i. Note that the behavior of InTopK differs from the TopK op in its handling of ties; if multiple classes have the same prediction value and straddle the top-k boundary, all of those classes are considered to be in the top k.
Activity
kofd commentedon Nov 21, 2015
Check out tf.nn.top_k(input, k, name=None) and tf.nn.in_top_k(predictions, targets, k, name=None).
vrv commentedon Nov 24, 2015
(let us know if those aren't sufficient)
neopostmodern commentedon Dec 1, 2015
I would suggest linking to the
tf.nn.top_kfunction in the documentation right afterargminandargmax, potentially under the name ofargsort(which is what Numpy users would search for).Summer12333 commentedon Jul 19, 2018
I've just met this question and I've found one function that is exactly what I want.
tf.nn.in_top_k(predictions, targets, k, name=None)
Says whether the targets are in the top K predictions.
This outputs a batch_size bool array, an entry out[i] is true if the prediction for the target class is among the top k predictions among all predictions for example i. Note that the behavior of InTopK differs from the TopK op in its handling of ties; if multiple classes have the same prediction value and straddle the top-k boundary, all of those classes are considered to be in the top k.
Update XNNPACK in XLA