{"action":"created","issue":{"url":"https://api.github.com/repos/caicloud/tensorflow-tutorial/issues/28","repository_url":"https://api.github.com/repos/caicloud/tensorflow-tutorial","labels_url":"https://api.github.com/repos/caicloud/tensorflow-tutorial/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/caicloud/tensorflow-tutorial/issues/28/comments","events_url":"https://api.github.com/repos/caicloud/tensorflow-tutorial/issues/28/events","html_url":"https://github.com/caicloud/tensorflow-tutorial/issues/28","id":228518659,"node_id":"MDU6SXNzdWUyMjg1MTg2NTk=","number":28,"title":"第八章 使用循环神经网络实现语言模型","user":{"login":"weizhenzhao","id":13706689,"node_id":"MDQ6VXNlcjEzNzA2Njg5","avatar_url":"https://avatars2.githubusercontent.com/u/13706689?v=4","gravatar_id":"","url":"https://api.github.com/users/weizhenzhao","html_url":"https://github.com/weizhenzhao","followers_url":"https://api.github.com/users/weizhenzhao/followers","following_url":"https://api.github.com/users/weizhenzhao/following{/other_user}","gists_url":"https://api.github.com/users/weizhenzhao/gists{/gist_id}","starred_url":"https://api.github.com/users/weizhenzhao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weizhenzhao/subscriptions","organizations_url":"https://api.github.com/users/weizhenzhao/orgs","repos_url":"https://api.github.com/users/weizhenzhao/repos","events_url":"https://api.github.com/users/weizhenzhao/events{/privacy}","received_events_url":"https://api.github.com/users/weizhenzhao/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-05-14T04:54:18Z","updated_at":"2018-07-05T16:18:00Z","closed_at":null,"author_association":"NONE","body":"        # 定义输出列表，在这里先将不同时刻LSTM结构的输出收集起来，再通过一个全连接层得到最终的输出\r\n        outputs = []\r\n        # state存储不同batch种LSTM的状态，将其初始化为0\r\n        state = self.initial_state\r\n        with tf.variable_scope(\"RNN\"):\r\n            for time_step in range(num_steps):\r\n                if time_step > 0: tf.get_variable_scope().reuse_variables()\r\n                # 从输入数据中获取当前时刻的输入并传入LSTM结构\r\n                cell_output, state = cell(inputs[:, time_step, :], state)                      **-----------------------这一行报错了**\r\n                # 当前输出加入输出队列\r\n                outputs.append(cell_output)\r\n        \r\n        # 把输出队列展开成[batch*hidden_size*num_steps]的形状，然后再\r\n        # reshape成[batch*numsteps,hidden_size]的形状\r\n        output = tf.reshape(tf.concat(1, outputs), [-1, HIDDEN_SIZE])\r\n\r\n\r\n\r\n\r\nTraceback (most recent call last):\r\n  File \"C:\\Users\\weizhen\\workspace\\TextUtil\\LanguageModel.py\", line 159, in <module>\r\n    tf.app.run()\r\n  File \"C:\\Users\\weizhen\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\tensorflow\\python\\platform\\app.py\", line 48, in run\r\n    _sys.exit(main(_sys.argv[:1] + flags_passthrough))\r\n  File \"C:\\Users\\weizhen\\workspace\\TextUtil\\LanguageModel.py\", line 135, in main\r\n    train_model = PTBModel(True, TRAIN_BATCH_SIZE, TRAIN_NUM_STEP)\r\n  File \"C:\\Users\\weizhen\\workspace\\TextUtil\\LanguageModel.py\", line 69, in __init__\r\n    cell_output, state = cell(inputs[:, time_step, :], state)\r\n  File \"C:\\Users\\weizhen\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\tensorflow\\contrib\\rnn\\python\\ops\\core_rnn_cell_impl.py\", line 953, in __call__\r\n    cur_inp, new_state = cell(cur_inp, cur_state)\r\n  File \"C:\\Users\\weizhen\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\tensorflow\\contrib\\rnn\\python\\ops\\core_rnn_cell_impl.py\", line 713, in __call__\r\n    output, new_state = self._cell(inputs, state, scope)\r\n  File \"C:\\Users\\weizhen\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\tensorflow\\contrib\\rnn\\python\\ops\\core_rnn_cell_impl.py\", line 235, in __call__\r\n    with _checked_scope(self, scope or \"basic_lstm_cell\", reuse=self._reuse):\r\n  File \"C:\\Users\\weizhen\\AppData\\Local\\Programs\\Python\\Python35\\lib\\contextlib.py\", line 59, in __enter__\r\n    return next(self.gen)\r\n  File \"C:\\Users\\weizhen\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\tensorflow\\contrib\\rnn\\python\\ops\\core_rnn_cell_impl.py\", line 77, in _checked_scope\r\n    type(cell).__name__))\r\nValueError: Attempt to reuse RNNCell <tensorflow.contrib.rnn.python.ops.core_rnn_cell_impl.BasicLSTMCell object at 0x00000215F1A63B00> with a different variable scope than its first use.  First use of cell was with scope 'language_model/RNN/multi_rnn_cell/cell_0/basic_lstm_cell', this attempt is with scope 'language_model/RNN/multi_rnn_cell/cell_1/basic_lstm_cell'.  Please create a new instance of the cell if you would like it to use a different set of weights.  If before you were using: MultiRNNCell([BasicLSTMCell(...)] * num_layers), change to: MultiRNNCell([BasicLSTMCell(...) for _ in range(num_layers)]).  If before you were using the same cell instance as both the forward and reverse cell of a bidirectional RNN, simply create two instances (one for forward, one for reverse).  In May 2017, we will start transitioning this cell's behavior to use existing stored weights, if any, when it is called with scope=None (which can lead to silent model degradation, so this error will remain until then.)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/caicloud/tensorflow-tutorial/issues/comments/402776607","html_url":"https://github.com/caicloud/tensorflow-tutorial/issues/28#issuecomment-402776607","issue_url":"https://api.github.com/repos/caicloud/tensorflow-tutorial/issues/28","id":402776607,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMjc3NjYwNw==","user":{"login":"caicloud-bot","id":14260140,"node_id":"MDQ6VXNlcjE0MjYwMTQw","avatar_url":"https://avatars0.githubusercontent.com/u/14260140?v=4","gravatar_id":"","url":"https://api.github.com/users/caicloud-bot","html_url":"https://github.com/caicloud-bot","followers_url":"https://api.github.com/users/caicloud-bot/followers","following_url":"https://api.github.com/users/caicloud-bot/following{/other_user}","gists_url":"https://api.github.com/users/caicloud-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/caicloud-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caicloud-bot/subscriptions","organizations_url":"https://api.github.com/users/caicloud-bot/orgs","repos_url":"https://api.github.com/users/caicloud-bot/repos","events_url":"https://api.github.com/users/caicloud-bot/events{/privacy}","received_events_url":"https://api.github.com/users/caicloud-bot/received_events","type":"User","site_admin":false},"created_at":"2018-07-05T16:18:00Z","updated_at":"2018-07-05T16:18:00Z","author_association":"CONTRIBUTOR","body":"Issues go stale after 90d of inactivity.\nMark the issue as fresh with `/remove-lifecycle stale`.\nStale issues rot after an additional 30d of inactivity and eventually close.\n\nPrevent issues from auto-closing with an `/lifecycle frozen` comment.\n\nIf this issue is safe to close now please do so with `/close`.\n\n/lifecycle stale"}}
{"actor":{"display_login":"caicloud-bot"}}