在照着tensorflow 官方文档和极客学院中tensorflow中文文档学习tensorflow时,遇到下面的两个问题:

1)AttributeError: module 'tensorflow' has no attribute 'sub'

#进入一个交互式Tensorflow会话
import tensorflow as tf
sess = tf.InteractiveSession()
x = tf.Variable([1.0,2.0])
a = tf.constant([3.0,3.0])
#使用初始化器initalizer op的run()方法初始化'x'
x.initializer.run()
#增加一个减法sub op, 从'x'减去'a',运行减去op,输出结果
sub = tf.sub(x,a)
print(sub.eval())
# 任务完成,关闭回话
sess.close()

执行时报错:

Traceback (most recent call last):
File "C:/PythonProj/tensorflow/first_tensorflow.py", line 43, in <module>
sub = tf.sub(x,a)
AttributeError: module 'tensorflow' has no attribute 'sub'

经过在pycharm中tf.自动反显的信息,我发现原来这个sub函数已经被subtract代替了,换成tf.subtract(x,a) ,ok ,一切顺利!

2)AttributeError: module 'tensorflow' has no attribute 'mul'

input1 = tf.constant(3.0)
input2 = tf.constant(2.0)
input3 = tf.constant(5.0) intermed = tf.add(input2,input3)
mul = tf.mul(input1,intermed)
with tf.Session() as sess:
result = sess.run([mul,intermed])
print(result)

报错信息为:

Traceback (most recent call last):
File "C:/PythonProj/tensorflow/first_tensorflow.py", line 78, in <module>
mul = tf.mul(input1,intermed)
AttributeError: module 'tensorflow' has no attribute 'mul'

同理,经过在pycharm中tf.反显信息的观察,我发现原来这个tf.mul函数已经被换成了tf.multiply了,修改后,ok!

tensorflow官方文档中的sub 和mul中的函数已经在API中改名了的更多相关文章

  1. 人工智能系统Google开源的TensorFlow官方文档中文版

    人工智能系统Google开源的TensorFlow官方文档中文版 2015年11月9日,Google发布人工智能系统TensorFlow并宣布开源,机器学习作为人工智能的一种类型,可以让软件根据大量的 ...

  2. TensorFlow官方文档

    关于<TensorFlow官方文档> <TensorFlow官方文档>原文地址:http://devdocs.io/tensorflow~python/ ,本次经过W3Csch ...

  3. TensorFlow 官方文档中文版【转】

    转自:http://wiki.jikexueyuan.com/project/tensorflow-zh/ TensorFlow 官方文档中文版 你正在阅读的项目可能会比 Android 系统更加深远 ...

  4. TensorFlow 官方文档中文版

    http://wiki.jikexueyuan.com/list/deep-learning/ TensorFlow 官方文档中文版 你正在阅读的项目可能会比 Android 系统更加深远地影响着世界 ...

  5. TensorFlow 官方文档中文版 --技术文档

    1.文档预览 2.文档下载 TensorFlow官方文档中文版-v1.2.pdf 提取码:pt7p

  6. TensorFlow 官方文档中文版学习

    TensorFlow 官方文档中文版 地址:http://wiki.jikexueyuan.com/project/tensorflow-zh/

  7. 在 Ubuntu 上安装 TensorFlow (官方文档的翻译)

    本指南介绍了如何在 Ubuntu 上安装 TensorFlow.这些指令也可能对其他 Linux 变体起作用, 但是我们只在Ubuntu 14.04 或更高版本上测试了(我们只支持)  这些指令. 一 ...

  8. 【TensorFlow官方文档】MNIST机器学习入门

    MNIST是一个入门级的计算机视觉数据集,它包含各种手写数字图片:它也包含每一张图片对应的标签,告诉我们这个是数字几.比如,下面这四张图片的标签分别是5,0,4,1. 从一个很简单的数学模型开始:训练 ...

  9. TensorFlow 官方文档 Programmer's Guide 中文翻译 —— 引言

    TensorFlow Programmer's Guide (Introduction) TensorFlow 编程手册 (引言) #(本项目对tensorflow官网上给出的指导手册(TF1.3版本 ...

随机推荐

  1. java面试笔试大汇总

    java面试笔试题大汇总5 JAVA相关基础知识 1.面向对象的特征有哪些方面 1.抽象:2.继承:3.封装:4. 多态性: 2.String是最基本的数据类型吗? 基本数据类型包括byte.int. ...

  2. [0] C# 扩展方法(Extension Method)

    有时有这样的情况,有一个类,你不能修改它,但你又想对它扩展(添加一个方法),这个时候就可以用到扩展方法了.请看下面的例子: using System;using System.Collections. ...

  3. asp.net web api实现图片点击式图片验证码

    现在验证码的形式越来越丰富,今天要实现的是在点击图片中的文字来进行校验的验证码,如图 这种验证码验证是验证鼠标是否选中了图片中文字的位置,以及选择的顺序,产生验证码的时候可以提供一组底图,然后随机获取 ...

  4. JavaScript面向对象轻松入门之继承(demo by ES5、ES6)

    继承是面向对象很重要的一个概念,分为接口继承和实现继承,接口继承即为继承某个对象的方法,实现继承即为继承某个对象的属性.JavvaScript通过原型链来实现接口继承.call()或apply()来实 ...

  5. [LeetCode] Friend Circles 朋友圈

    There are N students in a class. Some of them are friends, while some are not. Their friendship is t ...

  6. 【Android Developers Training】 88. 使用备份API

    注:本文翻译自Google官方的Android Developers Training文档,译者技术一般,由于喜爱安卓而产生了翻译的念头,纯属个人兴趣爱好. 原文链接:http://developer ...

  7. 使用python操作mysql数据库

    这是我之前使用mysql时用到的一些库及开发的工具,这里记录下,也方便我查阅. python版本: 2.7.13 mysql版本: 5.5.36 几个python库 1.mysql-connector ...

  8. Spring MVC 项目搭建 -4- spring security-添加自定义登录页面

    Spring MVC 项目搭建 -4- spring security-添加自定义登录页面 修改配置文件 <!--spring-sample-security.xml--> <!-- ...

  9. ASP搜索查询

    html code: <form name="frm_Search" method="get" action="Search.asp" ...

  10. Tornado+MySQL模拟SQL注入

    实验环境: python 3.6 + Tornado 4.5 + MySQL 5.7 实验目的: 简单模拟SQL注入,实现非法用户的成功登录 一.搭建环境 1.服务端的tornado主程序app.py ...