tensorflow2.1报no attribute 'Summary' && tf.contrib.summary instead

前后遇到两个错

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)

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章