遇到的问题以及对应解决方法
Transitioning to TensorFlow 1.0
TensorFlow升级导致的错误,TensorFlow 1.0后与以前代码不兼容,所以要根据API去修改。
参照外文:https://www.tensorflow.org/install/migration
1、解决问题AttributeError: module 'tensorflow' has no attribute 'histogram_summary'
将tf.histogram_summary改为tf.summary.histogram
成功解决AttributeError: module 'tensorflow' has no attribute 'histogram_summary'
2、解决问题AttributeError: module 'tensorflow' has no attribute 'scalar_summary'
将 tf.scalar_summary 改为tf.summary.scalar
3、解决问题AttributeError: module 'tensorflow' has no attribute 'merge_all_summaries'
将 tf.merge_all_summaries() 改为tf.summary.merge_all()
4、解决问题AttributeError: module 'tensorflow.python.training.training' has no attribute 'SummaryWriter'
将tf.train.SummaryWriter 改为tf.summary.FileWriter
5、解决问题Instructions for updating: Use `tf.global_variables_initializer` instead.
将tf.initialize_all_variables改为tf.global_variables_initializer
6、解决问题AttributeError: module 'tensorflow.python.ops.nn' has no attribute '_seq2seq'
将tf.nn.seq2seq.sequence_loss_by_example 改为tf.contrib.legacy_seq2seq.sequence_loss_by_example
7、将tf.nn.rnn_cell.改为 tf.contrib.rnn
8、解决问题:AttributeError: module 'tensorflow' has no attribute 'mul'
将tf.mul(input1, input2) 改为 tf.multiply(input1, input2)
TF版本升级问题:解决AttributeError: module 'tensorflow' has no attribute 'mul'
9、解决问题:AttributeError: module 'tensorflow' has no attribute 'sub'
将tf.sub改为tf.subtract
10、解决问题:
tf.merge_all_summaries() 改为 summary_op = tf.summaries.merge_all()
11、解决问题:AttributeError: 'module' object has no attribute 'SummaryWriter'
tf.train.SummaryWriter 改为 tf.summary.FileWriter
12、解决问题:AttributeError: module 'tensorflow.nn.rnn_cell' has no attribute 'linear'
tf.nn.rnn_cell 改为 tf.contrib.rnn.core_rnn_cell