{"action":"closed","issue":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/15418","repository_url":"https://api.github.com/repos/tensorflow/tensorflow","labels_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/15418/labels{/name}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/15418/comments","events_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/15418/events","html_url":"https://github.com/tensorflow/tensorflow/issues/15418","id":282650042,"number":15418,"title":"Eager:  `gradients_function` can't compute the gradient for simple functions","user":{"login":"hsm207","id":2398765,"avatar_url":"https://avatars0.githubusercontent.com/u/2398765?v=4","gravatar_id":"","url":"https://api.github.com/users/hsm207","html_url":"https://github.com/hsm207","followers_url":"https://api.github.com/users/hsm207/followers","following_url":"https://api.github.com/users/hsm207/following{/other_user}","gists_url":"https://api.github.com/users/hsm207/gists{/gist_id}","starred_url":"https://api.github.com/users/hsm207/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hsm207/subscriptions","organizations_url":"https://api.github.com/users/hsm207/orgs","repos_url":"https://api.github.com/users/hsm207/repos","events_url":"https://api.github.com/users/hsm207/events{/privacy}","received_events_url":"https://api.github.com/users/hsm207/received_events","type":"User","site_admin":false},"labels":[{"id":736653459,"url":"https://api.github.com/repos/tensorflow/tensorflow/labels/comp:eager","name":"comp:eager","color":"8cf260","default":false}],"state":"closed","locked":false,"assignee":{"login":"alextp","id":5061,"avatar_url":"https://avatars0.githubusercontent.com/u/5061?v=4","gravatar_id":"","url":"https://api.github.com/users/alextp","html_url":"https://github.com/alextp","followers_url":"https://api.github.com/users/alextp/followers","following_url":"https://api.github.com/users/alextp/following{/other_user}","gists_url":"https://api.github.com/users/alextp/gists{/gist_id}","starred_url":"https://api.github.com/users/alextp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alextp/subscriptions","organizations_url":"https://api.github.com/users/alextp/orgs","repos_url":"https://api.github.com/users/alextp/repos","events_url":"https://api.github.com/users/alextp/events{/privacy}","received_events_url":"https://api.github.com/users/alextp/received_events","type":"User","site_admin":false},"assignees":[{"login":"alextp","id":5061,"avatar_url":"https://avatars0.githubusercontent.com/u/5061?v=4","gravatar_id":"","url":"https://api.github.com/users/alextp","html_url":"https://github.com/alextp","followers_url":"https://api.github.com/users/alextp/followers","following_url":"https://api.github.com/users/alextp/following{/other_user}","gists_url":"https://api.github.com/users/alextp/gists{/gist_id}","starred_url":"https://api.github.com/users/alextp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alextp/subscriptions","organizations_url":"https://api.github.com/users/alextp/orgs","repos_url":"https://api.github.com/users/alextp/repos","events_url":"https://api.github.com/users/alextp/events{/privacy}","received_events_url":"https://api.github.com/users/alextp/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2017-12-16T20:55:58Z","updated_at":"2017-12-20T17:58:39Z","closed_at":"2017-12-20T17:58:39Z","author_association":"NONE","body":"Please go to Stack Overflow for help and support:\r\n\r\nhttps://stackoverflow.com/questions/tagged/tensorflow\r\n\r\nIf you open a GitHub issue, here is our policy:\r\n\r\n1. It must be a bug or a feature request.\r\n2. The form below must be filled out.\r\n3. It shouldn't be a TensorBoard issue. Those go [here](https://github.com/tensorflow/tensorboard/issues).\r\n\r\n**Here's why we have that policy**: TensorFlow developers respond to issues. We want to focus on work that benefits the whole community, e.g., fixing bugs and adding features. Support only helps individuals. GitHub also notifies thousands of people when issues are filed. We want them to see you communicating an interesting problem, rather than being redirected to Stack Overflow.\r\n\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)**: Yes\r\n- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**: Windows 10 64-bit\r\n- **TensorFlow installed from (source or binary)**: binary\r\n- **TensorFlow version (use command below)**: 1.5.0-dev20171215\r\n- **Python version**: 3.6.3 |Anaconda, Inc.| (default, Nov  8 2017, 15:10:56) [MSC v.1900 64 bit (AMD64)]\r\n- **Bazel version (if compiling from source)**: NA\r\n- **GCC/Compiler version (if compiling from source)**: NA\r\n- **CUDA/cuDNN version**: NA\r\n- **GPU model and memory**: NA\r\n- **Exact command to reproduce**: See description\r\n\r\nYou can collect some of this information using our environment capture script:\r\n\r\nhttps://github.com/tensorflow/tensorflow/tree/master/tools/tf_env_collect.sh\r\n\r\nYou can obtain the TensorFlow version with\r\n\r\npython -c \"import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)\"\r\n\r\n### Describe the problem\r\n\r\nFirst, define a loss function:\r\n\r\n```\r\nimport tensorflow as tf\r\nimport tensorflow.contrib.eager as tfe\r\ntfe.enable_eager_execution()\r\n\r\ndef loss(w):\r\n    prediction = 2 * w + 1\r\n    true_value = 11\r\n    return tf.cast((true_value - prediction)**2, tf.float32)\r\n```\r\n\r\nThen, compute the gradient when w=0.1:\r\n\r\n`tfe.gradients_function(loss)(0.1)`\r\n\r\nThe output is as expected. Next, compute the gradient when w=50:\r\n\r\n`tfe.gradients_function(loss)(50)`\r\n\r\nThe output is:\r\n\r\n`[None]`\r\n\r\nI expected the output to be 360 because the gradient is -40 + 8 w."}}
{"actor":{"display_login":"alextp"}}