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

# 进入一个交互式 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. UVALive - 3700 Interesting Yang Hui Triangle

    题目大意就是求一下 杨辉三角的第N行中不能被P整除的有多少个. 直接卢卡斯定理一下就行啦. #include<bits/stdc++.h> #define ll long long usi ...

  2. 获取非行间样式getComputedStyle

    有如下代码: 1 2 3 div {     width: 200px; } 1 2 3 <div id="aa" style="height: 100px;&qu ...

  3. can-i-win(好)

    https://leetcode.com/problems/can-i-win/ package com.company; import java.util.*; class Solution { / ...

  4. linux下脚本监控网络流量

    linux下脚本监控网络流量 学习了:https://blog.csdn.net/chenghuikai/article/details/48437479 学习了:http://www.jb51.ne ...

  5. nightwatch.js - scroll until element is visible

    .getLocationInView() Determine an element's location on the screen once it has been scrolled into vi ...

  6. 转 Python Selenium设计模式-POM

    前言 本文就python selenium自动化测试实践中所需要的POM设计模式进行分享,以便大家在实践中对POM的特点.应用场景和核心思想有一定的理解和掌握. 为什么要用POM 基于python s ...

  7. NYOJ 116 士兵杀敌(二)【线段树 单点更新】

    题意:题意非常清楚: 策略:如题. 这道题就是简单的线段树应用,据说还能够用树状数组来做,等我学了之后在说吧. 代码: #include<stdio.h> #include<stri ...

  8. 改动UITextfield的Placeholder字体的颜色

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/ ...

  9. WPF 后台Render线程崩溃, Exception from HRESULT: 0x88980406

    近期遇到一个问题.窗口在Loaded同一时候Resize会出现黑屏或者直接崩溃, 调查发现是WPF后端的Render线程渲染UI到DirectX时崩溃. 硬件环境:WES7 + .Net4.0 关于W ...

  10. NVIDIA GPU架构与原理分析(一)——GPU简介与主流Fermi、Kepler架构GPU概述

    1 GPU简介 图形处理单元GPU英文全称Graphic Processing Unit,GPU是相对于CPU的一个概念,NVIDIA公司在1999年发布GeForce256图形处理芯片时首先提出GP ...