{"action":"created","issue":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/5608","repository_url":"https://api.github.com/repos/tensorflow/tensorflow","labels_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/5608/labels{/name}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/5608/comments","events_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/5608/events","html_url":"https://github.com/tensorflow/tensorflow/issues/5608","id":189277343,"number":5608,"title":"How to dynamically select scope of untied variables during tf.while_loop?","user":{"login":"ethancaballero","id":5994634,"avatar_url":"https://avatars.githubusercontent.com/u/5994634?v=3","gravatar_id":"","url":"https://api.github.com/users/ethancaballero","html_url":"https://github.com/ethancaballero","followers_url":"https://api.github.com/users/ethancaballero/followers","following_url":"https://api.github.com/users/ethancaballero/following{/other_user}","gists_url":"https://api.github.com/users/ethancaballero/gists{/gist_id}","starred_url":"https://api.github.com/users/ethancaballero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethancaballero/subscriptions","organizations_url":"https://api.github.com/users/ethancaballero/orgs","repos_url":"https://api.github.com/users/ethancaballero/repos","events_url":"https://api.github.com/users/ethancaballero/events{/privacy}","received_events_url":"https://api.github.com/users/ethancaballero/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-15T01:46:31Z","updated_at":"2016-11-15T05:14:32Z","closed_at":null,"body":"When using python for loop, one simply creates/selects a new untied variable by using the incrementor to change the scope:\r\n```\r\nfor i range(num_untied_layers):  \r\n     with tf.variable_scope(\"untied_attention_hop\" + \"/\" + str(i)):\r\n          Wt = tf.get_variable(\"W_t\")\r\n          bt = tf.get_variable(\"bias_t\")\r\n```\r\n\r\nHow would one do this with tf.while_loop?\r\n\r\n@DeNeutoy"},"comment":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/comments/260549420","html_url":"https://github.com/tensorflow/tensorflow/issues/5608#issuecomment-260549420","issue_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/5608","id":260549420,"user":{"login":"DeNeutoy","id":16001974,"avatar_url":"https://avatars.githubusercontent.com/u/16001974?v=3","gravatar_id":"","url":"https://api.github.com/users/DeNeutoy","html_url":"https://github.com/DeNeutoy","followers_url":"https://api.github.com/users/DeNeutoy/followers","following_url":"https://api.github.com/users/DeNeutoy/following{/other_user}","gists_url":"https://api.github.com/users/DeNeutoy/gists{/gist_id}","starred_url":"https://api.github.com/users/DeNeutoy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DeNeutoy/subscriptions","organizations_url":"https://api.github.com/users/DeNeutoy/orgs","repos_url":"https://api.github.com/users/DeNeutoy/repos","events_url":"https://api.github.com/users/DeNeutoy/events{/privacy}","received_events_url":"https://api.github.com/users/DeNeutoy/received_events","type":"User","site_admin":false},"created_at":"2016-11-15T05:14:32Z","updated_at":"2016-11-15T05:14:32Z","body":"Another idea would be to use TensorArrays:\r\n\r\nAs before:\r\n```\r\nWt = []\r\nwith tf.variable_scope(\"one_weight_to_rule_them_all\"):\r\n    large_weight = tf.get_variable(\"Wt\", [max_steps*input_size, output_size])\r\n\r\n# The clear_after_read variable must be False, otherwise the TA will only allow you to read from that\r\n# index once.\r\nweight_container = tf.TensorArray(tf.float32, max_steps, clear_after_read=False, dynamic_size=None)\r\n\r\n# This initialises the TensorArray with the weights broken up in to pieces.\r\n# The reason this has to be a TensorArray is so that we can index it with a tensor(!)\r\nweight_container = weight_container.unpack(large_weight)\r\n\r\n# Now inside the while_loop with a counter variable AND the weight_container as a loop_var:\r\n\r\nweight_to_use = weight_container.read(counter)\r\n\r\n```\r\ncounter needs to be a integer scalar tensor which is incremented by one within the while_loop.\r\n\r\n"}}
{"actor":{"display_login":"DeNeutoy"}}