AttributeError: module 'tensorflow.python.ops.rnn' has no attribute 'rnn'

TensorFlow原版本报错:AttributeError: module 'tensorflow.python.ops.rnn' has no attribute 'rnn'

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)

应该替换为:

from tensorflow.contrib import rnn 


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

猜你喜欢

转载自blog.csdn.net/qq_33373858/article/details/83097027