前後遇到兩個錯
1、AttributeError: module tensorflow has no attribute 'Summary'
通過將 tf.Summary 換成 tf.compat.v1.Summary,可利用tensorflow 2.1.0接口自動轉換工具,將整個項目批量轉換
tf_upgrade_v2 \
--intree my_project/ \
--outtree my_project_v2/ \
--reportfile report.txt
替換完成後,遇到如下報錯
2、RuntimeError: tf.summary.FileWriter is not compatible with eager execution. Use tf.contrib.summary instead
tensorflow 2.1.0已經捨棄tf.contrib,不能這麼改。爲了不跟eager execution(tensorflow 2.1.0默認開啓)衝突,需在summary代碼前面關閉
tf.compat.v1.disable_eager_execution()
吐槽:百度根本找不到這些信息,推薦google
參考網頁:
1、 https://www.uedbox.com/post/54776/(google網址)
2、https://github.com/tensorflow/docs/blob/master/site/en/guide/upgrade.ipynb(接口轉換)
3、https://github.com/tensorflow/tensorflow/pull/36593(關閉eager execution)