首页 > 其他 > 详细

RuntimeError: The Session graph is empty. Add operations to the graph before calling run().解决方法

时间:2021-04-24 10:22:28      阅读:17      评论:0      收藏:0      [点我收藏+]

问题产生的原因:无法执行sess.run()的原因是tensorflow版本不同导致的,tensorflow版本2.0无法兼容版本1.0.
解决办法:
tf.compat.v1.disable_eager_execution()

import tensorflow as tf
tf.compat.v1.disable_eager_execution() #保证sess.run()能够正常运行
hello = tf.constant(‘hello,tensorflow‘)
sess= tf.compat.v1.Session()#版本2.0的函数
print(sess.run(hello))

后记:(1)对问题的认知,能够帮助自己快速定位问题。
      开始定位问题时,太懒,直接连英文的意思都没搞懂,就直接粘贴到百度去搜索,于是根本无法找到合适的答案。
   (2)明确问题,这个问题是图是空的,然后我去查看图建立的方法,没错,就是这样建立的。然后怀疑可能时无法执行sess.run()。
   (3)遇到问题,一定要深入思考一下,才是问题的根因,直接依据问题的表面去查找答案,根本无法找到。
参考链接:https://blog.csdn.net/sinat_36502563/article/details/102302392
参考链接:https://ask.csdn.net/questions/657580
————————————————
原文链接:https://blog.csdn.net/weixin_38410551/article/details/103631977

RuntimeError: The Session graph is empty. Add operations to the graph before calling run().解决方法

原文:https://www.cnblogs.com/swxj/p/14695880.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!