【发布时间】:2017-12-06 08:54:06
【问题描述】:
这是我用 jupyter 编写的 tensorflow RNN 网络代码的一部分。整个代码第一次运行完美,但是,运行它还会产生错误。代码:
x = tf.placeholder(tf.float32)
y = tf.placeholder(tf.float32)
def recurrent_nn_model(x):
x = tf.transpose(x, [1,0,2])
x = tf.reshape(x, [-1, chunk_size])
x = tf.split(x, n_chunks, 0)
lstm_layer = {'hidden_state': tf.zeros([n_batches, lstm_size]),
'current_state': tf.zeros([n_batches, lstm_size])}
layer = {'weights': tf.Variable(tf.random_normal([lstm_size, n_classes])),
'biases': tf.Variable(tf.random_normal([n_classes]))}
lstm = rnn_cell.BasicLSTMCell(lstm_size)
rnn_outputs, rnn_states = rnn.static_rnn(lstm, x, dtype=tf.float32)
output = tf.add(tf.matmul(rnn_outputs[-1], layer['weights']),
layer['biases'])
return output
错误是:
变量 rnn/basic_lstm_cell/kernel 已经存在,不允许。做过 你的意思是在 VarScope 中设置 reuse=True?最初定义于:
【问题讨论】:
标签: machine-learning tensorflow deep-learning lstm rnn