1. 程式人生 > >TF版本問題:由於不同的TensorFlow版本之間某些函式的用法引起的錯誤

TF版本問題:由於不同的TensorFlow版本之間某些函式的用法引起的錯誤

Transitioning to TensorFlow 1.0

參照外文:https://www.tensorflow.org/install/migration

1、解決問題AttributeError: module 'tensorflow' has no attribute 'histogram_summary'

將tf.histogram_summary改為tf.summary.histogram

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) 

9、解決問題:AttributeError: module 'tensorflow' has no attribute 'sub'

將將tf.sub改為tf.subtract