python kcws/train/train_cws_lstm.py出错
Closed this issue · 2 comments
python 2.7.5
tensorflow 1.0.1
前面都完成了,到了第四步kcws/train/train_cws_lstm.py出错了
(跟之前一位老兄出现的问题有点相似)
提示的错误为:
File "kcws/train/train_cws_lstm.py", line 276, in
tf.app.run()
File "/usr/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "kcws/train/train_cws_lstm.py", line 253, in main
test_unary_score, test_sequence_length = model.test_unary_score()
File "kcws/train/train_cws_lstm.py", line 175, in test_unary_score
P, sequence_length = self.inference(self.inp, reuse=True, trainMode=False)
File "kcws/train/train_cws_lstm.py", line 105, in inference
scope="RNN_forward")
File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/rnn.py", line 552, in dynamic_rnn
dtype=dtype)
File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/rnn.py", line 719, in _dynamic_rnn_loop
swap_memory=swap_memory)
File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2623, in while_loop
result = context.BuildLoop(cond, body, loop_vars, shape_invariants)
File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2456, in BuildLoop
pred, body, original_loop_vars, loop_vars, shape_invariants)
File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2406, in _BuildLoop
body_result = body(*packed_vars_for_body)
File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/rnn.py", line 702, in _time_step
skip_conditionals=True)
File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/rnn.py", line 177, in _rnn_step
new_output, new_state = call_cell()
File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/rnn.py", line 690, in
call_cell = lambda: cell(input_t, state)
File "/usr/lib/python2.7/site-packages/tensorflow/contrib/rnn/python/ops/core_rnn_cell_impl.py", line 405, in call
reuse=self._reuse) as unit_scope:
File "/usr/lib64/python2.7/contextlib.py", line 17, in enter
return self.gen.next()
File "/usr/lib/python2.7/site-packages/tensorflow/contrib/rnn/python/ops/core_rnn_cell_impl.py", line 100, in _checked_scope
"the argument reuse=True." % (scope_name, type(cell).name))
ValueError: Attempt to have a second RNNCell use the weights of a variable scope that already has weights: 'rnn_fwbw/RNN_forward/lstm_cell'; and the cell was not constructed as LSTMCell(..., reuse=True). To share the weights of an RNNCell, simply reuse it in your second calculation, or create a new one with the argument reuse=True.
之前一直按照步骤来执行的,没有修改代码,请问这是什么原因呢?谢谢~
你确认你的tensorflow是1.0.1的吗?
我也遇到这个问题,不过我的tensorflow版本是拉取了master分支编译的,版本是1.0.1rc。。。
后来我卸载了tensorflow并重新安装了1.0.1版本就好了。
问题已解决,谢谢~确实之前是master分支,重新安装1.0.1就好了,非常感谢!!!