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

# 进入一个交互式 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. Linux文件权限与属性详解 之 SUID、SGID&SBIT

    一.SetUID 1.Linux普通用户可以修改自己的密码,这个是一个合情合理的设置; 修改密码其实修改的是/etc/shadow这个文件,这个文件的属性: ----------. 1 root ro ...

  2. 济南day1下午

    下午 预:60+100+30 实:30+30+30 T1水题(water) T1写了二分图匹配 听说有70分,写挫了.... 正解:贪心,按长度排序, 对于第一幅牌里面的,在第二个里面,找一个长度小于 ...

  3. String,StringBuffer,StringBuilder源码分析

    1.类结构 String Diagrams StringBuffer Diagrams StringBuilder Diagrams 通过以上Diagrams可以看出,String,StringBuf ...

  4. iphone坐标系统

    1,基本概念 CGPoint{x,y};空间中的位置,通过x和y坐标定义 CGSize{width, height}; 大小,通过宽度和高度定义 CGRect{origin, size};位置和大小, ...

  5. 更新tensorflow支持GPU时出错

    sudo pip install --upgrade tensorflow-gpu Operation not permitted: '/tmp/pip-Sx_vMg-uninstall/System ...

  6. 【Nginx】开发一个HTTP过滤模块

    与HTTP处理模块不同.HTTP过滤模块的工作是对发送给用户的HTTP响应做一些加工. server返回的一个响应能够被随意多个HTTP过滤模块以流水线的方式依次处理.HTTP响应分为头部和包体,ng ...

  7. 怎样使用Entityframework.Extended

    这个插件真的非常有用,我们能够使用下面语法来简化我们的工作,下面不过演示样例: Deleting <strong>//delete all users where FirstName ma ...

  8. react 调用 function 的写法 及 解决 react onClick 方法自动执行

    1.react 调用方法的写法 (1)方式一 onClick={this.getFetchData.bind(this,item.id)} (2)方式二 getFetchData(e){ this.s ...

  9. sh脚本——#!/bin/bash

    #!/bin/bash是指此脚本使用/bin/bash来解释执行. 其中,#!是一个特殊的表示符,其后,跟着解释此脚本的shell路径. bash只是shell的一种,还有很多其它shell,如:sh ...

  10. java要在命令行执行eclipse的项目的方法

    在命令行运行eclipse的项目时须要把该项目生成一个能够运行的jar包,才干够在命令行下运行:分为两种情况,一种是项目中没有调用第三方的jar包,这样的比較简单.网上的资源也非常多,本文主要讲述第二 ...