官方的例子:运行之后出现以下错误

# 进入一个交互式 TensorFlow 会话.
import tensorflow as tf
sess = tf.InteractiveSession()x = tf.Variable([1.0, 2.0])
a = tf.constant([3.0, 3.0])# 使用初始化器 initializer op 的 run() 方法初始化 'x'
x.initializer.run()# 增加一个减法 sub op, 从 'x' 减去 'a'. 运行减法 op, 输出结果
sub = tf.sub(x, a)
print sub.eval()
# ==> [-2. -1.]

Traceback (most recent call last):File "C:\Users\lzm\Desktop\ten-1.py", line 10, in <module>sub = tf.sub(x, a)
AttributeError: module 'tensorflow' has no attribute 'sub'

出现这个问题是因为sub函数换名字了,换成了subtract

# 进入一个交互式 TensorFlow 会话.
import tensorflow as tf
sess = tf.InteractiveSession()x = tf.Variable([1.0, 2.0])
a = tf.constant([3.0, 3.0])# 使用初始化器 initializer op 的 run() 方法初始化 'x'
x.initializer.run()# 增加一个减法 sub op, 从 'x' 减去 'a'. 运行减法 op, 输出结果
sub = tf.subtract(x, a)
print sub.eval()
# ==> [-2. -1.]

转载于:https://www.cnblogs.com/QW-lzm/p/10499013.html

AttributeError: module 'tensorflow' has no attribute 'sub'相关推荐

  1. AttributeError: module ‘tensorflow‘ has no attribute ‘Session‘错误解决

    AttributeError: module 'tensorflow' has no attribute 'Session'错误解决 根据网上教程安装tensorflow环境时,最后都会有个测试代码用 ...

  2. AttributeError: module 'tensorflow' has no attribute 'random_normal'

    执行<TensorFlow实战Google深度学习框架(第2版)>only源代码 CH3 时如下语句报错 batch_size = 8 w1= tf.Variable(tf.random_ ...

  3. 问题解决——AttributeError: module ‘tensorflow‘ has no attribute ‘placeholder‘

    问题解决--AttributeError: module 'tensorflow' has no attribute 'placeholder' 参考文章: (1)问题解决--AttributeErr ...

  4. 问题:AttributeError: module 'tensorflow' has no attribute 'gfile'

    目录 问题 原因与解决方案 解决方案1 解决方案2 问题 运行如下代码 if not tf.gfile.exists(DATA_DIRECTORY):tf.gfile.makedirs(DATA_DI ...

  5. tensorflow版本问题导致的错误AttributeError: module ‘tensorflow‘ has no attribute ‘***‘

    问题解决--AttributeError: module 'tensorflow' has no attribute 'placeholder' - yuanyuanWu11 - 博客园 tensor ...

  6. 成功解决AttributeError: module ‘tensorflow‘ has no attribute ‘placeholder‘

    成功解决AttributeError: module 'tensorflow' has no attribute 'placeholder' 目录 解决问题 解决思路 解决方法 T1.降低tensor ...

  7. 成功解决AttributeError: module ‘tensorflow‘ has no attribute ‘contrib‘

    成功解决AttributeError: module 'tensorflow' has no attribute 'contrib' 目录 解决问题 解决思路 解决方法 解决方法

  8. 成功解决AttributeError: module ‘tensorflow‘ has no attribute ‘get_variable‘

    成功解决AttributeError: module 'tensorflow' has no attribute 'get_variable' 目录 解决问题 解决思路 解决方法 解决问题 Attri ...

  9. 成功解决AttributeError: module tensorflow has no attribute placeholder

    成功解决AttributeError: module 'tensorflow' has no attribute 'placeholder' 目录 解决问题 解决思路 解决方法 解决问题 Attrib ...

  10. 成功解决AttributeError: module tensorflow has no attribute random_normal

    成功解决AttributeError: module 'tensorflow' has no attribute 'random_normal' 目录 解决问题 解决思路 解决方法 解决问题 Attr ...

最新文章

  1. c++顺序容器vector用法
  2. CLR Via C# 3rd 阅读摘要 -- Chapter 24 – Runtime Serialization
  3. 3D 服务器端以向量计算为主的角色位置的算法
  4. 数据库3(DBUtils)
  5. UVa1588 | 算法竞赛入门经典(第二版) 习题3-11 换低档装置
  6. 使用 cx recipe 安装 Hybris Commerce Cloud 之后,遇到 indexer workder failed 错误
  7. c语言各种变量的优缺点,C语言优缺点
  8. visio 导出无边距的pdf 图
  9. 生物大数据时代,如何做好数据管理和再利用,发IF10+的数据库文章?
  10. 动态ip如何做域名解析?
  11. C++中lib和dll解析
  12. 突击计划——银行利息
  13. xsd 生成 java 类_如何从Java类生成XSD
  14. 模型退火的投资组合优化
  15. 挑netfilter的11个不足之处
  16. 波音737-800座位图哪个好_留学生坐飞机出国千万别选这些座位!航空公司不会告诉你的选座秘密........
  17. android W F 密码,这几种Android图形密码最常用 你也在用吗?
  18. 如何进行业务需求分析
  19. 区块链3.0 EOS和TRON
  20. 开放正成为华为下一阶段的战略竞争力

热门文章

  1. Linux Centos7安装hadoop3.x安装流程(跪舔文)
  2. 每天一道LeetCode-----平面上n个点,计算最多有多少个点在一条直线上
  3. c语言中oxb0常量是什么意思,C语言练习库V1.0
  4. macOS zip 打包加密和 unzip 解压
  5. 大神对飞控精准高度估计算法解读
  6. scikit-learn 朴素贝叶斯类库使用小结
  7. 拷贝构造函数编程实验
  8. Linux基础命令---删除用户userdel
  9. js 读取php页面内容,js读取html文件 js获取html页面显示内容
  10. 数组——两个有序数组的合并