tensorflow - 模块“张量流”没有属性“运行”
问题描述
代码:
import numpy as np
import tensorflow as tf
a3dim = np.array([[[1,2],[3,4]],
[[5,6],[7,8]]
])
print("a3dim Shape: ", a3dim.shape)
tf_t=tf.convert_to_tensor(a3dim,dtype=tf.float64)
print('tf_t : ',tf_t)
print('tf_t[0][0][0] : ',tf_t[0][0][0])
print('tf_t[1][1][1] : ',tf_t[1][1][1])
print('run(tf_t) : \n', tf.run(tf_t))
当我运行这个程序时,我有以下错误:
错误:
AttributeError Traceback (most recent call last)
<ipython-input-9-3506c45f6784> in <module>()
15 print('tf_t[1][1][1] : ',tf_t[1][1][1])
16
---> 17 print('run(tf_t) : \n', tf.run(tf_t))
AttributeError: module 'tensorflow' has no attribute 'run'
如何解决这个张量流问题?是版本问题吗?
解决方案
您必须首先创建一个会话才能运行, tf_t
然后才能运行session.run(tf_t)
。
推荐阅读
- android - android中的Google Pay(Tez)集成“从帐户中扣除金额但收款人未收到”的情况是什么?
- powershell - 更新模块帮助失败
- spring-boot - 使用特定主机名/ip 进行 Eureka 注册
- tensorflow - 使用 MirroredStrategy 时,tensorflow Estimator 是否对工作人员采取不同的批次?
- python - Python - 正则表达式模式
- python - Python,查找范围是否包含范围列表中的另一个较小范围
- go - Kubernetes 控制器的单元测试
- sql - Sybase Central - 为什么将此 VARCHAR 字段转换为 NUMERIC?
- javascript - 表单:根据电台选择将字段值发布到不同的字段
- google-app-engine - 运行时为php72时如何在appengine的默认队列中创建任务