qhduan / Seq2Seq_Chatbot_QA

使用TensorFlow实现的Sequence to Sequence的聊天机器人模型
793 stars 275 forks source link

请问windows下面运行s2s.py进行训练,报ValueError: Attempt to reuse RNNCell 的错误 #11

Open sainttelant opened 7 years ago

sainttelant commented 7 years ago

提示如下错误: Traceback (most recent call last): File "D:\python35\tensorexample\chatbotmodel\s2s.py", line 324, in tf.app.run() File "D:\python35\lib\site-packages\tensorflow\python\platform\app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "D:\python35\tensorexample\chatbotmodel\s2s.py", line 319, in main train() File "D:\python35\tensorexample\chatbotmodel\s2s.py", line 129, in train model = create_model(sess, False) File "D:\python35\tensorexample\chatbotmodel\s2s.py", line 110, in create_model dtype File "D:\python35\tensorexample\chatbotmodel\s2s_model.py", line 146, in init softmax_loss_function=softmax_loss_function File "D:\python35\lib\site-packages\tensorflow\contrib\legacy_seq2seq\python\ops\seq2seq.py", line 1201, in model_with_buckets decoder_inputs[:bucket[1]]) File "D:\python35\tensorexample\chatbotmodel\s2s_model.py", line 145, in lambda x, y: seq2seq_f(x, y, False), File "D:\python35\tensorexample\chatbotmodel\s2s_model.py", line 87, in seq2seq_f dtype=dtype File "D:\python35\lib\site-packages\tensorflow\contrib\legacy_seq2seq\python\ops\seq2seq.py", line 855, in embedding_attention_seq2seq encoder_cell, encoder_inputs, dtype=dtype) File "D:\python35\lib\site-packages\tensorflow\contrib\rnn\python\ops\core_rnn.py", line 197, in static_rnn (output, state) = call_cell() File "D:\python35\lib\site-packages\tensorflow\contrib\rnn\python\ops\core_rnn.py", line 184, in callcell = lambda: cell(input, state) File "D:\python35\lib\site-packages\tensorflow\contrib\rnn\python\ops\core_rnn_cell_impl.py", line 881, in call return self._cell(embedded, state) File "D:\python35\lib\site-packages\tensorflow\contrib\rnn\python\ops\core_rnn_cell_impl.py", line 953, in call cur_inp, new_state = cell(cur_inp, cur_state) File "D:\python35\lib\site-packages\tensorflow\contrib\rnn\python\ops\core_rnn_cell_impl.py", line 713, in call output, new_state = self._cell(inputs, state, scope) File "D:\python35\lib\site-packages\tensorflow\contrib\rnn\python\ops\core_rnn_cell_impl.py", line 235, in call with _checked_scope(self, scope or "basic_lstm_cell", reuse=self._reuse): File "D:\python35\lib\contextlib.py", line 59, in enter return next(self.gen) File "D:\python35\lib\site-packages\tensorflow\contrib\rnn\python\ops\core_rnn_cell_impl.py", line 77, in _checked_scope type(cell).name)) ValueError: Attempt to reuse RNNCell <tensorflow.contrib.rnn.python.ops.core_rnn_cell_impl.BasicLSTMCell object at 0x000000000AF340B8> with a different variable scope than its first use. First use of cell was with scope 'embedding_attention_seq2seq/rnn/multi_rnn_cell/cell_0/basic_lstm_cell', this attempt is with scope 'embedding_attention_seq2seq/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(...)] * numlayers), 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.)

sainttelant commented 7 years ago

请问如何解决?有遇到同样问题的吗? 好像是RNNCell要设置成 reuse=TRUE?

sainttelant commented 7 years ago

if i don't run train_model bash, instead of s2s.py only, how could i set up parameters(size,num_layers, epoch,etcs) as i wish ?

sainttelant commented 7 years ago

you can setup parameters in s2s.py, where tf.app.flags.define_float{} etc.

wangsanpeng commented 6 years ago

同样遇到这个问题,我的linux环境一样的错误,mac上边就没有错误,怀疑是tensorflow版本问题。。