变量rnn / basic_lstm_cell / kernel已存在,不允许使用。您是要在VarScope中设置“ reuse = True”还是“ reuse = tf.AUTO_REUSE”?

时间:2018-12-25 10:36:06

标签: python tensorflow rnn

任何人都可以帮助解决这个问题...? 我为RNN学习编写了一个代码,但是在输入输出行时出现了错误。

X_one_hot = tf.one_hot(X, num_classes) # one_hot: 1 -> 0 1 0 0 0 0 0
cell = tf.contrib.rnn.BasicLSTMCell(num_units = rnn_hidden_size, state_is_tuple = True)
initial_state = cell.zero_state(batch_size, tf.float32)
outputs, _states = tf.nn.dynamic_rnn(cell, X_one_hot, initial_state = initial_state, dtype = tf.float32)

但是我遇到了这个问题

ValueError: Variable rnn/basic_lstm_cell/kernel already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope? Originally defined at:

File "C:\Users\82108\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1740, in __init__
self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access
File "C:\Users\82108\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 3414, in create_op
op_def=op_def)
File "C:\Users\82108\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)

0 个答案:

没有答案
相关问题