import tensorflow as tf
tf.reset_default_graph()
module ‘tensorflow’ has no attribute ‘reset_default_graph’
tf.reset_default_graph()
修改为tf.compat.v1.reset_default_graph()
module ‘tensorflow’ has no attribute ‘placeholder’
tf.placeholder
修改为tf.compat.v1.placeholder
tf.placeholder() is not compatible with eager execution.
添加语句tf.compat.v1.disable_eager_execution()
module ‘tensorflow’ has no attribute ‘Session’
tf.Session()
改为tf.compat.v1.Session()
module ‘tensorflow’ has no attribute ‘contrib’
contrib.rnn.BasicLSTMCell
改为tf.compat.v1.nn.rnn_cell.BasicLSTMCell
tf.contrib.rnn.DropoutWrapper
改为tf.compat.v1.nn.rnn_cell.DropoutWrapper
tf.nn.dynamic_rnn
改为tf.compat.v1.nn.dynamic_rnn
module ‘tensorflow’ has no attribute ‘truncated_normal’
tf.truncated_normal
改为tf.random.truncated_normal
module ‘tensorflow._api.v2.train’ has no attribute ‘AdamOptimizer’
tf.train.AdamOptimizer
改为tf.optimizers.Adam
module ‘tensorboard.summary._tf.summary’ has no attribute ‘merge_all’
tf.summary.merge_all()
改为tf.compat.v1.summary.merge_all()
module ‘tensorboard.summary._tf.summary’ has no attribute ‘FileWriter’
tf.summary.FileWriter
改为tf.compat.v1.summary.FileWriter
module ‘tensorflow’ has no attribute ‘InteractiveSession’
tf.InteractiveSession()
改为tf.compat.v1.InteractiveSession()
module ‘tensorflow._api.v2.train’ has no attribute ‘Saver’
tf.train.Saver()
改为tf.compat.v1.train.Saver()