报错
ValueError: Variable hello/rnn/basic_lstm_cell/weights already exists, disallowed. Did you mean to set reuse=True in VarScope? Originally defined at
因为之前的cell kernel还在运行,如果使用的两个不同的cell,用variable scope指明
with tf.variable_scope('forward'): self.lstm_fw_cell = rnn_cell.BasicLSTMCell(dim_hidden) with tf.variable_scope('backward'): self.lstm_bw_cell = rnn_cell.BasicLSTMCell(dim_hidden)
如果使用的是相同的cell,将cell中的reuse设为True
rnn.BasicLSTMCell(num_hidden, forget_bias=1.0, reuse = True)
文章来源: tensorflow入门笔记二