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

# 进入一个交互式 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.]

AttributeError: module 'tensorflow' has no attribute 'sub'的更多相关文章

  1. AttributeError: module 'tensorflow' has no attribute 'enable_eager_execution'

    Traceback (most recent call last): File "linear_regression_eager_api.py", line 15, in < ...

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

      版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/qq_33440324/article/ ...

  3. python3 ,AttributeError: module 'tensorflow' has no attribute 'merge_summary'

    error:tensorflow有些方法属性被改了, self.summary_writer = tf.train.SummaryWriter(summary_dir)改为:summary.FileW ...

  4. AttributeError: module 'tensorflow' has no attribute 'set_random_seed'

    anaconda3 python3.7 安装好tensorflow 后出现上面的问题,原因是安装的tensorflow版本是2.0的,所以使用以前的代码tensorflow中的函数不兼容.

  5. Debug 路漫漫-14:Python: AttributeError: module 'tensorflow' has no attribute 'sub'

    在调试 <Neural Factorization Machines for Sparse Predictive Analytics>论文的源码(https://github.com/he ...

  6. Tensorflow之AttributeError: module 'tensorflow' has no attribute 'mul'

      tf.mul已经在新版本中被移除,请使用 tf.multiply 代替

  7. 【pycharm】pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法

    pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法 解决方法: 在pycharm的安装目 ...

  8. AttributeError: module ‘tensorflow.python.ops.nn’ has no attribute ‘leaky_relu’

    #AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'leaky_relu' 的原因主要是版本的问题 解决方法是更新 ...

  9. 启动Tensorboard时发生错误:class BeholderHook(tf.estimator.SessionRunHook): AttributeError: module 'tensorflow.python.estimator.estimator_lib' has no attribute 'SessionRunHook'

    报错:class BeholderHook(tf.estimator.SessionRunHook):AttributeError: module 'tensorflow.python.estimat ...

随机推荐

  1. TCP11种状态

    2.全部11种状态 2.1.客户端独有的:(1)SYN_SENT (2)FIN_WAIT1 (3)FIN_WAIT2 (4)CLOSING (5)TIME_WAIT . 2.2.服务器独有的:(1)L ...

  2. Spring配置项之<aop:aspectj-autoproxy />

    通过配置织入@Aspectj切面 虽然可以通过编程的方式织入切面,但是一般情况下,我们还是使用spring的配置自动完成创建代理织入切面的工作. 通过aop命名空间的<aop:aspectj-a ...

  3. 在谈MVP之前,你真的懂MVC吗?

    最近看到很多文章在谈论MVP或者MVVM模式的,但其实无论MVP还是MVVM都只是MVC模式的一种变种.而如果你对MVC的设计理念都还没有理解透彻,那么即使换成MVP亦或MVVM也不可能让你杂乱不堪的 ...

  4. [反汇编练习] 160个CrackMe之036

    [反汇编练习] 160个CrackMe之036. 本系列文章的目的是从一个没有任何经验的新手的角度(其实就是我自己),一步步尝试将160个CrackMe全部破解,如果可以,通过任何方式写出一个类似于注 ...

  5. [反汇编练习] 160个CrackMe之033

    [反汇编练习] 160个CrackMe之033. 本系列文章的目的是从一个没有任何经验的新手的角度(其实就是我自己),一步步尝试将160个CrackMe全部破解,如果可以,通过任何方式写出一个类似于注 ...

  6. C++11 并发指南四(<future> 详解一 std::promise 介绍)(转)

    前面两讲<C++11 并发指南二(std::thread 详解)>,<C++11 并发指南三(std::mutex 详解)>分别介绍了 std::thread 和 std::m ...

  7. Spring <context:annotation-config> 和 <context:component-scan>区别

    转自:http://www.cnblogs.com/leiOOlei/p/3713989.html <context:annotation-config> 和 <context:co ...

  8. Java基础:抽象类和接口

    转载请注明出处:jiq•钦's technical Blog 一.引言 基于面向对象五大原则中的以下两个原则,我们应该多考虑使用接口和抽象类: 里氏替换原则:子类能够通过实现父类接口来替换父类,所以父 ...

  9. windows下redis安装以及简单配置

    1.下载redis 下载地址https://github.com/dmajkic/redis/downloads.有32bit和64bit根据自己需要选择就可以了. 2.安装redis 首先使用cmd ...

  10. docker安全最佳实践概述

    /************************************************* * Author : Samson * Date : 08/07/2015 * Test plat ...