'tensorflow.python.ops.nn' has no attribute 'rnn_cell

For people using the newer version of tensorflow, add this to the code:

from tensorflow.contrib import rnn 


lstm_cell = rnn.BasicLSTMCell(rnn_size) 
outputs, states = rnn.static_rnn(lstm_cell, x, dtype=tf.float32)

instead of

from tensorflow.python.ops import rnn, rnn_cell 
lstm_cell = rnn_cell.BasicLSTMCell(rnn_size,state_is_tuple=True) 
outputs, states = rnn.rnn(lstm_cell, x, dtype=tf.float32)

猜你喜欢

转载自blog.csdn.net/zgqcs55/article/details/84309004