tensorflow1.x版本叫以前有很大改动,那个rnn的cell和别的一些地方有了作用域,具体可以看官网,下面是报错和解决办法。
ValueError: Variable hello/rnn/basic_lstm_cell/weights already exists, disallowed. Did you mean to set reuse=True in VarScope? Originally defined at
Traceback (most recent call last):
File "F:/Deep/Deep/githubLSTM.py", line 232, in <module>
prediction()
File "F:/Deep/Deep/githubLSTM.py", line 107, in prediction
output_rnn,final_states=tf.nn.dynamic_rnn(cell, input_rnn,initial_state=init_state, dtype=tf.float32) #output_rnn是记录lstm每个输出节点的结果,final_states是最后一个cell的结果
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\rnn.py", line 546, in dynamic_rnn
dtype=dtype)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\rnn.py", line 713, in _dynamic_rnn_loop
swap_memory=swap_memory)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\control_flow_ops.py", line 2605, in while_loop
result = context.BuildLoop(cond, body, loop_vars, shape_invariants)
File "C:\Users\Administrator\AppData\Local\Pr

在TensorFlow 1.x版本中,RNN Cell的使用需要指定变量作用域,以避免参数共享导致的名称冲突。错误通常提示未明确指示在第二个作用域中复用变量。解决方案包括为每个LSTM Cell设置不同的变量作用域,或者在加载已保存的权重时,确保正确使用reuse=True属性。注意,仅在非首个Cell上设置reuse=True,否则会引发找不到变量的错误。
最低0.47元/天 解锁文章
5346

被折叠的 条评论
为什么被折叠?



