Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

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

Open
sainttelant opened this issue Jul 19, 2017 · 5 comments

Comments

@sainttelant
Copy link

No description provided.

@sainttelant sainttelant changed the title 请问windows下面运行苏 请问windows下面运行s2s.py进行训练,报ValueError: Attempt to reuse RNNCell 的错误 Jul 19, 2017
@sainttelant
Copy link
Author

提示如下错误:
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
call_cell = 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(...)] * 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.)

@sainttelant
Copy link
Author

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

@sainttelant
Copy link
Author

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
Copy link
Author

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

@wangsanpeng
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants