{"action":"created","issue":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/2255","repository_url":"https://api.github.com/repos/tensorflow/tensorflow","labels_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/2255/labels{/name}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/2255/comments","events_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/2255/events","html_url":"https://github.com/tensorflow/tensorflow/issues/2255","id":153518419,"number":2255,"title":"Calculating Gradients Through tf.complex64 Numbers","user":{"login":"LeavesBreathe","id":14891677,"avatar_url":"https://avatars.githubusercontent.com/u/14891677?v=3","gravatar_id":"","url":"https://api.github.com/users/LeavesBreathe","html_url":"https://github.com/LeavesBreathe","followers_url":"https://api.github.com/users/LeavesBreathe/followers","following_url":"https://api.github.com/users/LeavesBreathe/following{/other_user}","gists_url":"https://api.github.com/users/LeavesBreathe/gists{/gist_id}","starred_url":"https://api.github.com/users/LeavesBreathe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LeavesBreathe/subscriptions","organizations_url":"https://api.github.com/users/LeavesBreathe/orgs","repos_url":"https://api.github.com/users/LeavesBreathe/repos","events_url":"https://api.github.com/users/LeavesBreathe/events{/privacy}","received_events_url":"https://api.github.com/users/LeavesBreathe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"yuanbyu","id":2342391,"avatar_url":"https://avatars.githubusercontent.com/u/2342391?v=3","gravatar_id":"","url":"https://api.github.com/users/yuanbyu","html_url":"https://github.com/yuanbyu","followers_url":"https://api.github.com/users/yuanbyu/followers","following_url":"https://api.github.com/users/yuanbyu/following{/other_user}","gists_url":"https://api.github.com/users/yuanbyu/gists{/gist_id}","starred_url":"https://api.github.com/users/yuanbyu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuanbyu/subscriptions","organizations_url":"https://api.github.com/users/yuanbyu/orgs","repos_url":"https://api.github.com/users/yuanbyu/repos","events_url":"https://api.github.com/users/yuanbyu/events{/privacy}","received_events_url":"https://api.github.com/users/yuanbyu/received_events","type":"User","site_admin":false},"milestone":null,"comments":5,"created_at":"2016-05-06T19:09:00Z","updated_at":"2016-05-22T22:41:02Z","closed_at":null,"body":"Hey TF,\r\n\r\nIts very nice that you support so many complex number calculations like `tf.complex_abs` and `fft`. I am trying replicate this [Associative LSTM paper ](http://arxiv.org/abs/1602.03032)where complex numbers are needed. \r\n\r\nHowever, when I try to calculate the gradient using `tf.gradient`, I get the traceback below. Is it not possible to calculate the gradient if complex numbers are used with type `tf.complex64`? If not, this would be an incredibly useful feature as there are several new RNN papers that require complex numbers to be used. \r\n\r\nI am initializing a `tf.complex64` dtype weight matrix as follows:\r\n```python\r\n      if complex_weights: \r\n        a = tf.truncated_normal([total_arg_size, output_size], stddev=0.1)\r\n        weight_matrix = tf.Variable(tf.complex(a,a), name=\"Complex_Weight\")\r\n```\r\n\r\nPerhaps I'm missing something or not writing the code properly. I have TF 0.8 installed. \r\n\r\n```python\r\n    gradients = tf.gradients(self.average_mean_loss, params)\r\n  File \"/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gradients.py\", line 481, in gradients\r\n    in_grads = _AsList(grad_fn(op, *out_grads))\r\n  File \"/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/math_grad.py\", line 414, in _DivGrad\r\n    return (array_ops.reshape(math_ops.reduce_sum(grad / y, rx), sx),\r\n  File \"/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/math_ops.py\", line 526, in r_binary_op_wrapper\r\n    x = ops.convert_to_tensor(x, dtype=y.dtype.base_dtype, name=\"x\")\r\n  File \"/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py\", line 566, in convert_to_tensor\r\n    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)\r\n  File \"/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gradients.py\", line 94, in _IndexedSlicesToTensor\r\n    name=name)\r\n  File \"/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_math_ops.py\", line 1759, in unsorted_segment_sum\r\n    num_segments=num_segments, name=name)\r\n  File \"/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/op_def_library.py\", line 486, in apply_op\r\n    _Attr(op_def, input_arg.type_attr))\r\n  File \"/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/op_def_library.py\", line 59, in _SatisfiesTypeConstraint\r\n    \", \".join(dtypes.as_dtype(x).name for x in allowed_list)))\r\nTypeError: DataType complex64 for attr 'T' not in list of allowed values: float32, float64, int32, int64, uint8, int16, int8, uint16```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/comments/220861055","html_url":"https://github.com/tensorflow/tensorflow/issues/2255#issuecomment-220861055","issue_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/2255","id":220861055,"user":{"login":"stevenhutt","id":6261087,"avatar_url":"https://avatars.githubusercontent.com/u/6261087?v=3","gravatar_id":"","url":"https://api.github.com/users/stevenhutt","html_url":"https://github.com/stevenhutt","followers_url":"https://api.github.com/users/stevenhutt/followers","following_url":"https://api.github.com/users/stevenhutt/following{/other_user}","gists_url":"https://api.github.com/users/stevenhutt/gists{/gist_id}","starred_url":"https://api.github.com/users/stevenhutt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevenhutt/subscriptions","organizations_url":"https://api.github.com/users/stevenhutt/orgs","repos_url":"https://api.github.com/users/stevenhutt/repos","events_url":"https://api.github.com/users/stevenhutt/events{/privacy}","received_events_url":"https://api.github.com/users/stevenhutt/received_events","type":"User","site_admin":false},"created_at":"2016-05-22T22:41:02Z","updated_at":"2016-05-22T22:41:02Z","body":"As a temporary solution you could replace the FFT with a DFT. More memory and slower, but at least you can replicate the paper."}}
{"actor":{"display_login":"stevenhutt"}}