{"action":"opened","number":6832,"pull_request":{"url":"https://api.github.com/repos/tensorflow/tensorflow/pulls/6832","id":101470156,"html_url":"https://github.com/tensorflow/tensorflow/pull/6832","diff_url":"https://github.com/tensorflow/tensorflow/pull/6832.diff","patch_url":"https://github.com/tensorflow/tensorflow/pull/6832.patch","issue_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/6832","number":6832,"state":"open","locked":false,"title":"GridRNN cell uses tuples for output and states","user":{"login":"phvu","id":1087992,"avatar_url":"https://avatars.githubusercontent.com/u/1087992?v=3","gravatar_id":"","url":"https://api.github.com/users/phvu","html_url":"https://github.com/phvu","followers_url":"https://api.github.com/users/phvu/followers","following_url":"https://api.github.com/users/phvu/following{/other_user}","gists_url":"https://api.github.com/users/phvu/gists{/gist_id}","starred_url":"https://api.github.com/users/phvu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phvu/subscriptions","organizations_url":"https://api.github.com/users/phvu/orgs","repos_url":"https://api.github.com/users/phvu/repos","events_url":"https://api.github.com/users/phvu/events{/privacy}","received_events_url":"https://api.github.com/users/phvu/received_events","type":"User","site_admin":false},"body":"In response to this (https://github.com/tensorflow/tensorflow/issues/2560) and recent changes in LSTMCell, this PR added `state_is_tuple=True` and `output_is_tuple=True` into the constructor of GridRNNCell:\r\n\r\n```\r\n> cell = tf.contrib.grid_rnn.Grid2LSTMCell(3, use_peepholes=True)\r\n> cell.state_size\r\n       (LSTMStateTuple(c=3, h=3), LSTMStateTuple(c=3, h=3))\r\n> cell.output_size\r\n       (3,)\r\n```\r\n\r\nThis means there are 2 LSTM cells in the grid, and the state of each cell has size of `(c=3, h=3)`. There is only one output dimension, whose size is 3.\r\n\r\nIn contrast:\r\n\r\n```\r\n> cell = tf.contrib.grid_rnn.Grid2BasicRNNCell(3)\r\n> cell.state_size\r\n     (3, 3)\r\n> cell.output_size\r\n     (3,)\r\n```\r\n\r\nThis means there are 2 BasicRNN cell in the grid, and the state of each cell has size of 3. There is only one output dimension, whose size is 3.\r\n\r\nPrevious behaviour is maintained by using `state_is_tuple=False, output_is_tuple=False` when creating the cell.\r\n\r\n```\r\n> cell = tf.contrib.grid_rnn.Grid2LSTMCell(3, use_peepholes=True, state_is_tuple=False, output_is_tuple=False)\r\n    WARNING:tensorflow:<tensorflow.contrib.grid_rnn.python.ops.grid_rnn_cell.Grid2LSTMCell object at 0x10de68f50>: Using a concatenated state is slower and will soon be deprecated.  Use state_is_tuple=True.\r\n    WARNING:tensorflow:<tensorflow.contrib.grid_rnn.python.ops.grid_rnn_cell.Grid2LSTMCell** object at 0x10de68f50>: Using a concatenated output is slower and will soon be deprecated.  Use output_is_tuple=True.\r\n\r\n> cell.state_size\r\n    12\r\n> cell.output_size\r\n    3\r\n\r\n> cell = tf.contrib.grid_rnn.Grid2BasicRNNCell(3, state_is_tuple=False, output_is_tuple=False)\r\n    WARNING:tensorflow:<tensorflow.contrib.grid_rnn.python.ops.grid_rnn_cell.Grid2BasicRNNCell object at 0x10de4b950>: Using a concatenated state is slower and will soon be deprecated.  Use state_is_tuple=True.\r\n    WARNING:tensorflow:<tensorflow.contrib.grid_rnn.python.ops.grid_rnn_cell.Grid2BasicRNNCell object at 0x10de4b950>: Using a concatenated output is slower and will soon be deprecated.  Use output_is_tuple=True.\r\n\r\n> cell.state_size\r\n   6\r\n> cell.output_size\r\n   3\r\n```\r\n\r\nThis also fixes https://github.com/tensorflow/tensorflow/issues/4296\r\n\r\n# Backward compatibility\r\nThis change is not fully backward-compatible:\r\n- The old implementation concatenates the output and the state tensors, so when you have `g, s = cell(...)` then `g` and `s` are simply two tensors.\r\n- This implementation, by default, returns `g` and `s` as tuples of tensors. \r\n  - `g` is a tuple of length equals to the size of `output_dims` of the cell. Normally you only have one output dimension, so `g` will be a tuple of length 1.\r\n  - `s` is a tuple of length equals to the size of `recurrent_dims` of the cell, containing the states of all the recurrent cells in all recurrent dimensions.\r\nNow if you use LSTM cells for the recurrent dimensions, the state of each LSTM cell is a tuple of tensors (with `c` and `h` components). So for instance, the state of a Grid2LSTMCell will be a tuple of tuples: `((c=<tensor>, h=<tensor>), (c=<tensor>, h=<tensor>))`\r\nIf you use GRU or vanila RNN cells for the recurrent dimensions, the state of each cell is a tensor. So for instance, the state of a Grid2GRUCell will be a tuple of tensors: `(<tensor>, <tensor>)`\r\n\r\nOld code that depends on this cell can use the old behaviour by setting `state_is_tuple=False` and `output_is_tuple=False` when constructing the cell. \r\n\r\n```\r\ncell = tf.contrib.grid_rnn.Grid2LSTMCell(2, use_peepholes=True,\r\n                                             state_is_tuple=False,\r\n                                             output_is_tuple=False)\r\n```","created_at":"2017-01-13T15:51:39Z","updated_at":"2017-01-13T15:51:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/tensorflow/tensorflow/pulls/6832/commits","review_comments_url":"https://api.github.com/repos/tensorflow/tensorflow/pulls/6832/comments","review_comment_url":"https://api.github.com/repos/tensorflow/tensorflow/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/6832/comments","statuses_url":"https://api.github.com/repos/tensorflow/tensorflow/statuses/0e903b053717ff45f07f14997175c9f673359b44","head":{"label":"phvu:fix/grid-rnn","ref":"fix/grid-rnn","sha":"0e903b053717ff45f07f14997175c9f673359b44","user":{"login":"phvu","id":1087992,"avatar_url":"https://avatars.githubusercontent.com/u/1087992?v=3","gravatar_id":"","url":"https://api.github.com/users/phvu","html_url":"https://github.com/phvu","followers_url":"https://api.github.com/users/phvu/followers","following_url":"https://api.github.com/users/phvu/following{/other_user}","gists_url":"https://api.github.com/users/phvu/gists{/gist_id}","starred_url":"https://api.github.com/users/phvu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phvu/subscriptions","organizations_url":"https://api.github.com/users/phvu/orgs","repos_url":"https://api.github.com/users/phvu/repos","events_url":"https://api.github.com/users/phvu/events{/privacy}","received_events_url":"https://api.github.com/users/phvu/received_events","type":"User","site_admin":false},"repo":{"id":53394185,"name":"tensorflow","full_name":"phvu/tensorflow","owner":{"login":"phvu","id":1087992,"avatar_url":"https://avatars.githubusercontent.com/u/1087992?v=3","gravatar_id":"","url":"https://api.github.com/users/phvu","html_url":"https://github.com/phvu","followers_url":"https://api.github.com/users/phvu/followers","following_url":"https://api.github.com/users/phvu/following{/other_user}","gists_url":"https://api.github.com/users/phvu/gists{/gist_id}","starred_url":"https://api.github.com/users/phvu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phvu/subscriptions","organizations_url":"https://api.github.com/users/phvu/orgs","repos_url":"https://api.github.com/users/phvu/repos","events_url":"https://api.github.com/users/phvu/events{/privacy}","received_events_url":"https://api.github.com/users/phvu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/phvu/tensorflow","description":"Computation using data flow graphs for scalable machine learning","fork":true,"url":"https://api.github.com/repos/phvu/tensorflow","forks_url":"https://api.github.com/repos/phvu/tensorflow/forks","keys_url":"https://api.github.com/repos/phvu/tensorflow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/phvu/tensorflow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/phvu/tensorflow/teams","hooks_url":"https://api.github.com/repos/phvu/tensorflow/hooks","issue_events_url":"https://api.github.com/repos/phvu/tensorflow/issues/events{/number}","events_url":"https://api.github.com/repos/phvu/tensorflow/events","assignees_url":"https://api.github.com/repos/phvu/tensorflow/assignees{/user}","branches_url":"https://api.github.com/repos/phvu/tensorflow/branches{/branch}","tags_url":"https://api.github.com/repos/phvu/tensorflow/tags","blobs_url":"https://api.github.com/repos/phvu/tensorflow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/phvu/tensorflow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/phvu/tensorflow/git/refs{/sha}","trees_url":"https://api.github.com/repos/phvu/tensorflow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/phvu/tensorflow/statuses/{sha}","languages_url":"https://api.github.com/repos/phvu/tensorflow/languages","stargazers_url":"https://api.github.com/repos/phvu/tensorflow/stargazers","contributors_url":"https://api.github.com/repos/phvu/tensorflow/contributors","subscribers_url":"https://api.github.com/repos/phvu/tensorflow/subscribers","subscription_url":"https://api.github.com/repos/phvu/tensorflow/subscription","commits_url":"https://api.github.com/repos/phvu/tensorflow/commits{/sha}","git_commits_url":"https://api.github.com/repos/phvu/tensorflow/git/commits{/sha}","comments_url":"https://api.github.com/repos/phvu/tensorflow/comments{/number}","issue_comment_url":"https://api.github.com/repos/phvu/tensorflow/issues/comments{/number}","contents_url":"https://api.github.com/repos/phvu/tensorflow/contents/{+path}","compare_url":"https://api.github.com/repos/phvu/tensorflow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/phvu/tensorflow/merges","archive_url":"https://api.github.com/repos/phvu/tensorflow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/phvu/tensorflow/downloads","issues_url":"https://api.github.com/repos/phvu/tensorflow/issues{/number}","pulls_url":"https://api.github.com/repos/phvu/tensorflow/pulls{/number}","milestones_url":"https://api.github.com/repos/phvu/tensorflow/milestones{/number}","notifications_url":"https://api.github.com/repos/phvu/tensorflow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/phvu/tensorflow/labels{/name}","releases_url":"https://api.github.com/repos/phvu/tensorflow/releases{/id}","deployments_url":"https://api.github.com/repos/phvu/tensorflow/deployments","created_at":"2016-03-08T08:07:09Z","updated_at":"2016-11-04T12:53:59Z","pushed_at":"2017-01-13T15:50:06Z","git_url":"git://github.com/phvu/tensorflow.git","ssh_url":"git@github.com:phvu/tensorflow.git","clone_url":"https://github.com/phvu/tensorflow.git","svn_url":"https://github.com/phvu/tensorflow","homepage":"http://tensorflow.org","size":83682,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"tensorflow:master","ref":"master","sha":"018583b064f40fa1f3cabb7eef0a5ac6b169275d","user":{"login":"tensorflow","id":15658638,"avatar_url":"https://avatars.githubusercontent.com/u/15658638?v=3","gravatar_id":"","url":"https://api.github.com/users/tensorflow","html_url":"https://github.com/tensorflow","followers_url":"https://api.github.com/users/tensorflow/followers","following_url":"https://api.github.com/users/tensorflow/following{/other_user}","gists_url":"https://api.github.com/users/tensorflow/gists{/gist_id}","starred_url":"https://api.github.com/users/tensorflow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tensorflow/subscriptions","organizations_url":"https://api.github.com/users/tensorflow/orgs","repos_url":"https://api.github.com/users/tensorflow/repos","events_url":"https://api.github.com/users/tensorflow/events{/privacy}","received_events_url":"https://api.github.com/users/tensorflow/received_events","type":"Organization","site_admin":false},"repo":{"id":45717250,"name":"tensorflow","full_name":"tensorflow/tensorflow","owner":{"login":"tensorflow","id":15658638,"avatar_url":"https://avatars.githubusercontent.com/u/15658638?v=3","gravatar_id":"","url":"https://api.github.com/users/tensorflow","html_url":"https://github.com/tensorflow","followers_url":"https://api.github.com/users/tensorflow/followers","following_url":"https://api.github.com/users/tensorflow/following{/other_user}","gists_url":"https://api.github.com/users/tensorflow/gists{/gist_id}","starred_url":"https://api.github.com/users/tensorflow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tensorflow/subscriptions","organizations_url":"https://api.github.com/users/tensorflow/orgs","repos_url":"https://api.github.com/users/tensorflow/repos","events_url":"https://api.github.com/users/tensorflow/events{/privacy}","received_events_url":"https://api.github.com/users/tensorflow/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tensorflow/tensorflow","description":"Computation using data flow graphs for scalable machine learning","fork":false,"url":"https://api.github.com/repos/tensorflow/tensorflow","forks_url":"https://api.github.com/repos/tensorflow/tensorflow/forks","keys_url":"https://api.github.com/repos/tensorflow/tensorflow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tensorflow/tensorflow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tensorflow/tensorflow/teams","hooks_url":"https://api.github.com/repos/tensorflow/tensorflow/hooks","issue_events_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/events{/number}","events_url":"https://api.github.com/repos/tensorflow/tensorflow/events","assignees_url":"https://api.github.com/repos/tensorflow/tensorflow/assignees{/user}","branches_url":"https://api.github.com/repos/tensorflow/tensorflow/branches{/branch}","tags_url":"https://api.github.com/repos/tensorflow/tensorflow/tags","blobs_url":"https://api.github.com/repos/tensorflow/tensorflow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tensorflow/tensorflow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tensorflow/tensorflow/git/refs{/sha}","trees_url":"https://api.github.com/repos/tensorflow/tensorflow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tensorflow/tensorflow/statuses/{sha}","languages_url":"https://api.github.com/repos/tensorflow/tensorflow/languages","stargazers_url":"https://api.github.com/repos/tensorflow/tensorflow/stargazers","contributors_url":"https://api.github.com/repos/tensorflow/tensorflow/contributors","subscribers_url":"https://api.github.com/repos/tensorflow/tensorflow/subscribers","subscription_url":"https://api.github.com/repos/tensorflow/tensorflow/subscription","commits_url":"https://api.github.com/repos/tensorflow/tensorflow/commits{/sha}","git_commits_url":"https://api.github.com/repos/tensorflow/tensorflow/git/commits{/sha}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/comments{/number}","issue_comment_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/comments{/number}","contents_url":"https://api.github.com/repos/tensorflow/tensorflow/contents/{+path}","compare_url":"https://api.github.com/repos/tensorflow/tensorflow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tensorflow/tensorflow/merges","archive_url":"https://api.github.com/repos/tensorflow/tensorflow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tensorflow/tensorflow/downloads","issues_url":"https://api.github.com/repos/tensorflow/tensorflow/issues{/number}","pulls_url":"https://api.github.com/repos/tensorflow/tensorflow/pulls{/number}","milestones_url":"https://api.github.com/repos/tensorflow/tensorflow/milestones{/number}","notifications_url":"https://api.github.com/repos/tensorflow/tensorflow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tensorflow/tensorflow/labels{/name}","releases_url":"https://api.github.com/repos/tensorflow/tensorflow/releases{/id}","deployments_url":"https://api.github.com/repos/tensorflow/tensorflow/deployments","created_at":"2015-11-07T01:19:20Z","updated_at":"2017-01-13T15:30:16Z","pushed_at":"2017-01-13T15:45:28Z","git_url":"git://github.com/tensorflow/tensorflow.git","ssh_url":"git@github.com:tensorflow/tensorflow.git","clone_url":"https://github.com/tensorflow/tensorflow.git","svn_url":"https://github.com/tensorflow/tensorflow","homepage":"http://tensorflow.org","size":83666,"stargazers_count":42923,"watchers_count":42923,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":19913,"mirror_url":null,"open_issues_count":815,"forks":19913,"open_issues":815,"watchers":42923,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tensorflow/tensorflow/pulls/6832"},"html":{"href":"https://github.com/tensorflow/tensorflow/pull/6832"},"issue":{"href":"https://api.github.com/repos/tensorflow/tensorflow/issues/6832"},"comments":{"href":"https://api.github.com/repos/tensorflow/tensorflow/issues/6832/comments"},"review_comments":{"href":"https://api.github.com/repos/tensorflow/tensorflow/pulls/6832/comments"},"review_comment":{"href":"https://api.github.com/repos/tensorflow/tensorflow/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tensorflow/tensorflow/pulls/6832/commits"},"statuses":{"href":"https://api.github.com/repos/tensorflow/tensorflow/statuses/0e903b053717ff45f07f14997175c9f673359b44"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":1,"review_comments":0,"maintainer_can_modify":true,"commits":1,"additions":654,"deletions":385,"changed_files":2}}
{"actor":{"display_login":"phvu"}}