AttributeError: module 'tensorflow' has no attribute 'reset_default_graph' 解决

问题如下:
在这里插入图片描述
AttributeError: module ‘tensorflow’ has no attribute ‘reset_default_graph’

上面是因为安装的Tensorflow 2不支持Tensorflow1的API而报的错
,需要将导入模块的部分进行更改,操作如下:

1,原本的代码

import tensorflow as tf %这行代码改成下面的两行代码

2,替换成如下代码:

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

3,可以了,不会报错
在这里插入图片描述

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