想运行这行代码
tf.reset_default_graph()
然后出了错
AttributeError: module ‘tensorflow’ has no attribute ‘reset_default_graph’
解决方法:
将导包部分的
import tensorflow as tf
更改为
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
更:
我的TensorFlow版本是2.4.0

运行截图:

本文介绍了如何解决在TensorFlow 2.x版本中遇到的“module 'tensorflow' has no attribute 'reset_default_graph'”错误。通过调整导入模块的方式并禁用V2行为,可以成功在TensorFlow 2.4.0环境中运行原本为早期版本设计的代码。

1万+

被折叠的 条评论
为什么被折叠?



