tensorflow报错问题及解决方案记录页

tensorflow报错问题及解决方案记录页,第1张

tensorflow报错问题及解决方案记录

环境:
tensorflow:2.1
keras:2.3.1

因为偶尔就会出现这些问题,每次都得重新搜索解决方案很麻烦,所以在此记录一下,持续更新


以下报错的原因是python代码是基于TensorFlow1.0+的,而系统中的TensorFlow版本为2.0+

报错:

AttributeError: module ‘tensorflow’ has no attribute 'ConfigProto’

将原句:

config = tf.ConfigProto()

改为

config = tf.compat.v1.ConfigProto()

报错:

RuntimeError: set_session is not available when using TensorFlow 2.0.

将原句:

KTF.set_session(session)

改为:

tf.compat.v1.keras.backend.set_session(session)

报错:
AttributeError: module ‘tensorflow’ has no attribute 'Session’
将原句:

sess = tf.Session()

改为:

sess = tf.compat.v1.Session()

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5657680.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存