使用TensorFlow2.x运行sess.run()时,出现如下错误:
RuntimeError: The Session graph is empty. Add operations to the graph before calling run().
原因是TensorFlow1.x和TensorFlow2.x的语法不兼容
解决方法如下:
在引入代码所需要的包之后,紧跟着使用下列代码声明一下。
tf.compat.v1.disable_eager_execution()
使用TensorFlow2.x运行sess.run()时,出现如下错误:
RuntimeError: The Session graph is empty. Add operations to the graph before calling run().
原因是TensorFlow1.x和TensorFlow2.x的语法不兼容
解决方法如下:
在引入代码所需要的包之后,紧跟着使用下列代码声明一下。
tf.compat.v1.disable_eager_execution()