1
我想在不使用MultiRNNCell的情況下製作多層RNN,因爲我想獨立更新每個圖層。所以我沒有使用tf.dynamic_rnn。Tensorflow RNN variable_scope error
with tf.variable_scope("cell"):
with tf.variable_scope("cell_1", reuse=True):
cell_1 = tf.contrib.rnn.BasicLSTMCell(n_hidden)
states_1 = cell_1.zero_state(batch_size, tf.float32)
with tf.variable_scope("cell_2", reuse=True):
cell_2 = tf.contrib.rnn.BasicLSTMCell(n_hidden)
states_2 = cell_2.zero_state(batch_size, tf.float32)
with tf.variable_scope("cell_3", reuse=True):
cell_3 = tf.contrib.rnn.BasicLSTMCell(n_hidden)
states_3 = cell_3.zero_state(batch_size, tf.float32)
outputs_1=[]
outputs_2=[]
outputs_3=[]
with tf.variable_scope("architecture"):
for i in range(n_step):
output_1, states_1 = cell_1(X[:, i], states_1)
output_2, states_2 = cell_2(output_1, states_2)
output_3, states_3 = cell_3(output_2, states_3)
outputs_3.append(output_3)
然後我得到這樣的錯誤。
ValueError: Variable architecture/basic_lstm_cell/kernel already exists, disallowed. Did you mean to set reuse=True in VarScope?
因此,似乎不可能在沒有MultiRNNCell的情況下聲明張量流中的多個單元。我該如何解決這個問題?