ROLO icon indicating copy to clipboard operation
ROLO copied to clipboard

ValueError: Variable rnn/lstm_cell/kernel does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=None in VarScope?

Open Tomingz opened this issue 8 years ago • 4 comments

I use tensorflow1.3+python3.5 in windows,so i change the code like this: def LSTM_single(self, name, _X, _istate, _weights, _biases): with tf.device('/gpu:0'): # input shape: (batch_size, n_steps, n_input) 1-3-5002 _X = tf.transpose(_X, [1, 0, 2]) # permute num_steps and batch_size # Reshape to prepare input to hidden activation _X = tf.reshape(_X, [self.num_steps * self.batch_size, self.num_input]) # (num_steps*batch_size, num_input) # Split data because rnn cell needs a list of inputs for the RNN inner loop #_X = tf.split(0, self.num_steps, _X) # n_steps * (batch_size, num_input) #x = tf.split(x, n_steps, 0) 1.2之后的版本改了 _X = tf.split(_X, self.num_steps, 0)

    cell = tf.contrib.rnn.LSTMCell(self.num_input,state_is_tuple=False) #tf.nn.rnn_cell
    state = _istate
    for step in range(self.num_steps):
         outputs, state = tf.contrib.rnn.static_rnn(cell, [_X[step]],state, dtype=tf.float32) #tf.nn.rnn  tf.nn.rnn_cell.BasicLSTMCell 
    tf.get_variable_scope().reuse_variables()
    return outputs

when I run ROLO_network_test_all.py there is a error like this: ValueError: Variable rnn/lstm_cell/kernel does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=None in VarScope? how to sovle it? maybe we can discuss it . my email:[email protected]

Tomingz avatar Apr 13 '18 12:04 Tomingz

did you solve your problem?The problem i met is the same as yours.

opalby avatar Dec 19 '18 13:12 opalby

you should write your code in this way

tf.variable_scope(name): cell = tf.contrib.rnn.LSTMCell(self.num_input,state_is_tuple=False) #tf.nn.rnn_cell state = _istate for step in range(self.num_steps): outputs, state = tf.contrib.rnn.static_rnn(cell, [_X[step]],state, dtype=tf.float32) #tf.nn.rnn
tf.nn.rnn_cell.BasicLSTMCell tf.get_variable_scope().reuse_variables() return outputs

zhangcj5131 avatar Mar 20 '20 08:03 zhangcj5131

you should write your code in this way

tf.variable_scope(name): cell = tf.contrib.rnn.LSTMCell(self.num_input,state_is_tuple=False) #tf.nn.rnn_cell state = _istate for step in range(self.num_steps):

outputs, state = tf.contrib.rnn.static_rnn(cell, [_X[step]],state, dtype=tf.float32) #tf.nn.rnn

tf.nn.rnn_cell.BasicLSTMCell

tf.get_variable_scope().reuse_variables()__

return outputs

zhangcj5131 avatar Mar 20 '20 08:03 zhangcj5131

you should write your code in this way

tf.variable_scope(name): cell = tf.contrib.rnn.LSTMCell(self.num_input,state_is_tuple=False) #tf.nn.rnn_cell state = _istate for step in range(self.num_steps):

outputs, state = tf.contrib.rnn.static_rnn(cell, [_X[step]],state, dtype=tf.float32) #tf.nn.rnn

tf.nn.rnn_cell.BasicLSTMCell

tf.get_variable_scope().reuse_variables()__

return outputs

你好,请问一下你又成功运行起来ROLO吗,能不能留个联系方式啊,我跑的时候遇到一些问题想要咨询一下您

czc00125 avatar Nov 24 '20 09:11 czc00125