1
ここはjupyterで書かれたテンソルフローのRNNネットワークコードの一部です。コード全体が初めて完全に実行されますが、さらに実行するとエラーが発生します。コード:Tensorflow:変数rnn/basic_lstm_cell/kernelは既に存在し、許可されていません
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
エラーがある:
Variable rnn/basic_lstm_cell/kernel already exists, disallowed. Did you mean to set reuse=True in VarScope? Originally defined at:
私は両方の方法を試しましたが、エラーが発生しました。 ValueError:入力グラフとレイヤーグラフが同じではありません:Tensor( "split:0"、shape =(?, 28)、dtype = float32)は、グラフで。 –
これは、グラフをリセットしているが、一部のノードを再定義していないことを意味します。あなたのノートブックがどのように組織されているか – Maxim