{"action":"opened","issue":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/20009","repository_url":"https://api.github.com/repos/tensorflow/tensorflow","labels_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/20009/labels{/name}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/20009/comments","events_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/20009/events","html_url":"https://github.com/tensorflow/tensorflow/issues/20009","id":332324306,"node_id":"MDU6SXNzdWUzMzIzMjQzMDY=","number":20009,"title":"tf.get_variable(reuse=tf.AUTO_REUSE) is not working in the eager execution mode.","user":{"login":"David-Mao","id":12476624,"node_id":"MDQ6VXNlcjEyNDc2NjI0","avatar_url":"https://avatars3.githubusercontent.com/u/12476624?v=4","gravatar_id":"","url":"https://api.github.com/users/David-Mao","html_url":"https://github.com/David-Mao","followers_url":"https://api.github.com/users/David-Mao/followers","following_url":"https://api.github.com/users/David-Mao/following{/other_user}","gists_url":"https://api.github.com/users/David-Mao/gists{/gist_id}","starred_url":"https://api.github.com/users/David-Mao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/David-Mao/subscriptions","organizations_url":"https://api.github.com/users/David-Mao/orgs","repos_url":"https://api.github.com/users/David-Mao/repos","events_url":"https://api.github.com/users/David-Mao/events{/privacy}","received_events_url":"https://api.github.com/users/David-Mao/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-14T09:34:58Z","updated_at":"2018-06-14T09:34:58Z","closed_at":null,"author_association":"NONE","body":"\r\n------------------------\r\n\r\n### System information\r\n- **Have I written custom code (as opposed to using a stock example script provided in TensorFlow)**:\r\nNo\r\n- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**:\r\nDarwin localhost 17.5.0 Darwin Kernel Version 17.5.0: Fri Apr 13 19:32:32 PDT 2018; root:xnu-4570.51.2~1/RELEASE_X86_64 x86_64\r\nMac OS X 10.13.4\r\n- **TensorFlow installed from (source or binary)**: binary\r\n- **TensorFlow version (use command below)**: 1.7\r\n- **Python version**: 2.7\r\n- **Bazel version (if compiling from source)**: N/A\r\n- **GCC/Compiler version (if compiling from source)**: N/A\r\n- **CUDA/cuDNN version**: N/A\r\n- **GPU model and memory**: N/A\r\n- **Exact command to reproduce**: See below\r\n\r\n\r\n### Describe the problem\r\n\r\nWhen calling get_variable() function in tensorflow, the behavior of the \"reuse\" flag is defined in the [tensorflow api doc](https://www.tensorflow.org/api_docs/python/tf/variable_scope) to be AUTO_REUSE:\r\n\r\n> reuse: True, None, or tf.AUTO_REUSE; ... **When eager execution is enabled, this argument is always forced to be tf.AUTO_REUSE**.\r\n\r\nHowever when I run the demo code as suggested in the api doc:\r\n\r\n```\r\ntf.enable_eager_execution()\r\ndef foo():\r\n  with tf.variable_scope(\"foo\", reuse=tf.AUTO_REUSE):\r\n    v = tf.get_variable(\"v\", [1])\r\n  return v\r\nv1 = foo()  # Creates v.\r\nv2 = foo()  # Gets the same, existing v.\r\nassert v1 == v2\r\n```\r\n\r\nIt fails. (It passes if the first line is removed, as expected.)\r\n\r\nNot sure whether it is a bug or expected behavior, but at least the api doc seems kind of misleading. If it's expected, then what's the correct way to reuse a variable in eager mode? (and can this be included in the api doc?)"}}
{"actor":{"display_login":"David-Mao"}}