{"action":"created","issue":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/319","repository_url":"https://api.github.com/repos/tensorflow/tensorflow","labels_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/319/labels{/name}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/319/comments","events_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/319/events","html_url":"https://github.com/tensorflow/tensorflow/issues/319","id":118222702,"node_id":"MDU6SXNzdWUxMTgyMjI3MDI=","number":319,"title":"Argmax, fetching top 5 probabilities","user":{"login":"RamaneekGill","id":6265772,"node_id":"MDQ6VXNlcjYyNjU3NzI=","avatar_url":"https://avatars1.githubusercontent.com/u/6265772?v=4","gravatar_id":"","url":"https://api.github.com/users/RamaneekGill","html_url":"https://github.com/RamaneekGill","followers_url":"https://api.github.com/users/RamaneekGill/followers","following_url":"https://api.github.com/users/RamaneekGill/following{/other_user}","gists_url":"https://api.github.com/users/RamaneekGill/gists{/gist_id}","starred_url":"https://api.github.com/users/RamaneekGill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RamaneekGill/subscriptions","organizations_url":"https://api.github.com/users/RamaneekGill/orgs","repos_url":"https://api.github.com/users/RamaneekGill/repos","events_url":"https://api.github.com/users/RamaneekGill/events{/privacy}","received_events_url":"https://api.github.com/users/RamaneekGill/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2015-11-21T21:41:54Z","updated_at":"2018-07-19T07:31:40Z","closed_at":"2015-11-24T19:45:59Z","author_association":"NONE","body":"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.\n\n```\ncorrect_prediction = tf.equal(tf.argmax(activation, 1), tf.argmax(y, 1))\naccuracy = tf.reduce_mean(tf.cast(correct_prediction, \"float\"))\nprint (\"ACCURACY IS:\")\nprint sess.run(accuracy, feed_dict={x: data.test_set.inputs(), y: data.test_set.targets()})\n```\n\nFrom 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)`\n\nSomething like this would be nice:\n\n```\ncorrect_prediction = tf.contains(tf.argmax(activation, dim, N_VALUES_TO_FETCH), tf.argmax(y, dim)\n```\n\nCan anyone help me with the problem I am facing? Thank you.\n"},"comment":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/comments/406182590","html_url":"https://github.com/tensorflow/tensorflow/issues/319#issuecomment-406182590","issue_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/319","id":406182590,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNjE4MjU5MA==","user":{"login":"Summer12333","id":32533222,"node_id":"MDQ6VXNlcjMyNTMzMjIy","avatar_url":"https://avatars1.githubusercontent.com/u/32533222?v=4","gravatar_id":"","url":"https://api.github.com/users/Summer12333","html_url":"https://github.com/Summer12333","followers_url":"https://api.github.com/users/Summer12333/followers","following_url":"https://api.github.com/users/Summer12333/following{/other_user}","gists_url":"https://api.github.com/users/Summer12333/gists{/gist_id}","starred_url":"https://api.github.com/users/Summer12333/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Summer12333/subscriptions","organizations_url":"https://api.github.com/users/Summer12333/orgs","repos_url":"https://api.github.com/users/Summer12333/repos","events_url":"https://api.github.com/users/Summer12333/events{/privacy}","received_events_url":"https://api.github.com/users/Summer12333/received_events","type":"User","site_admin":false},"created_at":"2018-07-19T07:31:40Z","updated_at":"2018-07-19T07:31:40Z","author_association":"NONE","body":"I've just met this question and I've found one function that is exactly what I want.\r\n\r\n**tf.nn.in_top_k(predictions, targets, k, name=None)** \r\nSays whether the targets are in the top K predictions.\r\nThis 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."}}
{"actor":{"display_login":"Summer12333"}}