python - 启用 Eager Execution 时,Tensor.graph 毫无意义
问题描述
a = tf.compat.v1.constant(5.0)
b = tf.compat.v1.constant(6.0)
sum1 = a + b
g = tf.compat.v1.Graph()
with g.as_default():
# Define operations and tensors in `g`.
hello = tf.compat.v1.constant('hello')
assert hello.graph is g
sess = tf.compat.v1.Session(graph=g)
print(sess.run(sum1))
tensorflow-gpu2.0 我不知道为什么。我是张量流的初学者
解决方案
导入 tensorflow 后需要禁用急切执行,如下所示:
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
它对我有用。
推荐阅读
- php - 我在打印存储在字符串变量中的 url 时在 php 中得到一个奇怪的输出
- python-3.x - 如何为不确定数量的选项的线图创建 Bokeh Select 菜单?
- java - (JAVA) Need to convert DATE to prepared statement for SQL
- google-chrome - 当图像的实际尺寸为 300x250 时,Chrome 检查器显示图像的固有尺寸为 1x1
- reactjs - 如何在组件重新渲染之前获取 Redux 状态?
- nginx - nginx 和 uwsgi 配置问题
- css - 为什么我的顶部标题位于导航菜单的顶部?
- c# - 当文件确实存在时,C# System.IO.FileNotFoundException
- angular - 从离子后退按钮导航后未触发 Ionic 4 ionViewDidEnter()
- app-store-connect - 删除路由应用程序覆盖文件时无法保存更改