ValueError: Trying to share variable rnn/multi_rnn_cell/cell_0/basic_lstm_cell/kernel

前端 未结 4 1170
予麋鹿
予麋鹿 2020-12-14 18:01

This it the code:

X = tf.placeholder(tf.float32, [batch_size, seq_len_1, 1], name=\'X\')
labels = tf.placeholder(tf.float32, [None, alpha_size], name=\'label         


        
4条回答
  •  有刺的猬
    2020-12-14 18:31

    I encountered a similar problem when I upgraded to v1.2 (tensorflow-gpu). Instead of using [rnn_cell]*3, I created 3 rnn_cells (stacked_rnn) by a loop (so that they don't share variables) and fed MultiRNNCell with stacked_rnn and the problem goes away. I'm not sure it is the right way to do it.

    stacked_rnn = []
    for iiLyr in range(3):
        stacked_rnn.append(tf.nn.rnn_cell.LSTMCell(num_units=512, state_is_tuple=True))
    MultiLyr_cell = tf.nn.rnn_cell.MultiRNNCell(cells=stacked_rnn, state_is_tuple=True)
    

提交回复
热议问题