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,可以了,不会报错
在这里插入图片描述

发布了34 篇原创文章 · 获赞 9 · 访问量 3040

猜你喜欢

转载自blog.csdn.net/RObot_123/article/details/103131567