{"action":"created","issue":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/15115","repository_url":"https://api.github.com/repos/tensorflow/tensorflow","labels_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/15115/labels{/name}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/15115/comments","events_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/15115/events","html_url":"https://github.com/tensorflow/tensorflow/issues/15115","id":279240779,"node_id":"MDU6SXNzdWUyNzkyNDA3Nzk=","number":15115,"title":"Wrong result when computing accuracy using tf.metrics.accuracy","user":{"login":"secsilm","id":8894643,"node_id":"MDQ6VXNlcjg4OTQ2NDM=","avatar_url":"https://avatars3.githubusercontent.com/u/8894643?v=4","gravatar_id":"","url":"https://api.github.com/users/secsilm","html_url":"https://github.com/secsilm","followers_url":"https://api.github.com/users/secsilm/followers","following_url":"https://api.github.com/users/secsilm/following{/other_user}","gists_url":"https://api.github.com/users/secsilm/gists{/gist_id}","starred_url":"https://api.github.com/users/secsilm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/secsilm/subscriptions","organizations_url":"https://api.github.com/users/secsilm/orgs","repos_url":"https://api.github.com/users/secsilm/repos","events_url":"https://api.github.com/users/secsilm/events{/privacy}","received_events_url":"https://api.github.com/users/secsilm/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2017-12-05T04:18:37Z","updated_at":"2018-12-20T12:53:19Z","closed_at":"2017-12-05T18:54:56Z","author_association":"CONTRIBUTOR","body":"### System information\r\n\r\n- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**: Windows 10 1709\r\n- **TensorFlow installed from (source or binary)**: pip\r\n- **TensorFlow version (use command below)**: 1.4.0\r\n- **Python version**: Python 3.5.2 :: Anaconda custom (64-bit)\r\n\r\n### Describe the problem\r\n\r\nI found the result `tf.metrics.accuracy` returns is incorrect when I trained my model. To verify this I wrote a  simple program.\r\n\r\n```python\r\nimport tensorflow as tf\r\n\r\nsess = tf.Session()\r\nlabels = tf.placeholder(tf.int32)\r\npredictions = tf.placeholder(tf.int32)\r\nacc, _ = tf.metrics.accuracy(labels, predictions)\r\nmy_acc = tf.reduce_mean(tf.cast(tf.equal(labels, predictions), tf.float32))\r\n\r\nfeed_dict = {\r\n    labels: [1, 2, 3, 4, 5], \r\n    predictions: [1, 2, 3, 4, 5]\r\n}\r\nsess.run(tf.global_variables_initializer())\r\nsess.run(tf.local_variables_initializer())\r\n\r\nsess.run(acc, feed_dict)  # 0.0\r\nsess.run(my_acc, feed_dict)  # 1.0\r\n```\r\n\r\nYou can see that `acc` and `my_acc` is different and acc is wrong. I double checked [the doc](https://www.tensorflow.org/api_docs/python/tf/metrics/accuracy) and still confused. Is there anything I missed? Thank you."},"comment":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/comments/448989314","html_url":"https://github.com/tensorflow/tensorflow/issues/15115#issuecomment-448989314","issue_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/15115","id":448989314,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0ODk4OTMxNA==","user":{"login":"dchatterjee172","id":10482742,"node_id":"MDQ6VXNlcjEwNDgyNzQy","avatar_url":"https://avatars0.githubusercontent.com/u/10482742?v=4","gravatar_id":"","url":"https://api.github.com/users/dchatterjee172","html_url":"https://github.com/dchatterjee172","followers_url":"https://api.github.com/users/dchatterjee172/followers","following_url":"https://api.github.com/users/dchatterjee172/following{/other_user}","gists_url":"https://api.github.com/users/dchatterjee172/gists{/gist_id}","starred_url":"https://api.github.com/users/dchatterjee172/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dchatterjee172/subscriptions","organizations_url":"https://api.github.com/users/dchatterjee172/orgs","repos_url":"https://api.github.com/users/dchatterjee172/repos","events_url":"https://api.github.com/users/dchatterjee172/events{/privacy}","received_events_url":"https://api.github.com/users/dchatterjee172/received_events","type":"User","site_admin":false},"created_at":"2018-12-20T12:53:19Z","updated_at":"2018-12-20T12:53:19Z","author_association":"NONE","body":"@reedwm \r\n`if mode == tf.estimator.ModeKeys.EVAL:`\r\n`            a = tf.random.uniform(dtype=tf.int32, maxval=1000, shape=[])`\r\n`            eval_metric_ops = {`\r\n `               \"eval_mean_bert_loss\": tf.metrics.mean(total_loss_bert),`\r\n`                \"eval_mean_original_loss\": tf.metrics.mean(total_loss_original),`\r\n`                \"eval_mean_loss\": tf.metrics.mean(a)}`\r\n`            output_spec = tf.estimator.EstimatorSpec(`\r\n`                mode=mode,`\r\n`                loss=a,`\r\n`                eval_metric_ops=eval_metric_ops)`       \r\n        \r\n`eval_spec = tf.estimator.EvalSpec(input_fn=eval_input_fn, steps=100, start_delay_secs=0,\r\n                                      throttle_secs=120)`\r\n\r\n[output](https://imgur.com/a/lT92UoU)      \r\nhow can `loss` and `eval_mean_loss` be exactly same? batch size is 1 here.\r\n\r\n"}}
{"actor":{"display_login":"dchatterjee172"}}