zoukankan      html  css  js  c++  java
  • RuntimeError: The Session graph is empty. Add operations to the graph before calling run().解决方法

    问题产生的原因:无法执行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

  • 相关阅读:
    数字基本数据类型范围比较
    java中float和double的区别
    ASP.NET中javascript与c#互相访问
    Javascript技术之详尽解析event对象
    Java基础-Java中的Calendar和Date类
    逻辑运算符
    JS获取当前时间
    几秒后刷新页面
    【LiteOS】LiteOS任务篇源码分析删除任务函数
    POJ 2385 Apple Catching (DP)
  • 原文地址:https://www.cnblogs.com/swxj/p/14695880.html
Copyright © 2011-2022 走看看