1
지금은 tensorflow에서 여러 GRU 반복 레이어를 서로 연결하려고합니다. 다음과 같은 오류가 발생합니다.Tensorflow, GRU 레이어를 연결하는 방법
ValueError: Variable GRUCell/Gates/Linear/Matrix already exists, disallowed. Did you mean to set reuse=True in VarScope? Originally defined at:
File "/home/chase/workspace/SentenceEncoder/sent_enc.py", line 42, in <module>
output, states[i] = grus[i](output, states[i])
여기 내 코드입니다.
x = tf.placeholder(tf.float32, (batch_size, time_steps, vlen), 'x')
y_exp = tf.placeholder(tf.float32, (batch_size, time_steps, vlen), 'y_exp')
with tf.name_scope('encoder'):
gru_sizes = (128, 256, 512)
grus = [tf.nn.rnn_cell.GRUCell(sz) for sz in gru_sizes]
states = [tf.zeros((batch_size, g.state_size)) for g in grus]
for t in range(time_steps):
output = tf.reshape(x[:, t, :], (batch_size, vlen))
for i in range(len(grus)):
output, states[i] = grus[i](output, states[i])
나는 tensorflow가 이것을하기 위해 MultiRNNCell을 제공한다는 것을 알고 있지만 나는 그 자신을 위해 그것을 알아 내고 싶다.