127、TensorFlow 计算图执行(二)
import tensorflow as tf
# Define a placeholder that expects a vector of three floating-point values
# and a computation that depends on it
x = tf.placeholder(tf.float32, shape=[3])
y = tf.square(x) with tf.Session() as sess:
# Feeding a value changes the result that is returned when you evaluate y
print(sess.run(y, {x:[1.0, 2.0, 3.0]})) # => "[1.0,4.0,9.0]"
print(sess.run(y, {x:[0.0, 0.0, 5.0]})) # => "[0.0,0.0,25.0]" # Raises "tf.errors.InvalidArgumentError" , because you must feed a value for
# a 'tf.placeholder()' when evaluating a tensor that depends on it
sess.run(y) # Raise 'ValueError', because the shape of 37.0 does not match the shape
# of placeholder x
sess.run(y, {x:37.0})
下面是输出的结果:
2018-02-17 11:11:35.215329: I C:\tf_jenkins\workspace\rel-win\M\windows\PY\35\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
[ 1. 4. 9.]
[ 0. 0. 25.]
127、TensorFlow 计算图执行(二)的更多相关文章
- tf中计算图 执行流程学习【转载】
转自:https://blog.csdn.net/dcrmg/article/details/79028003 https://blog.csdn.net/qian99/article/details ...
- TensorFlow 实战(二)—— tf.train(优化算法)
Training | TensorFlow tf 下以大写字母开头的含义为名词的一般表示一个类(class) 1. 优化器(optimizer) 优化器的基类(Optimizer base class ...
- tensorflow学习笔记二:入门基础 好教程 可用
http://www.cnblogs.com/denny402/p/5852083.html tensorflow学习笔记二:入门基础 TensorFlow用张量这种数据结构来表示所有的数据.用一 ...
- tensorflow笔记(二)之构造一个简单的神经网络
tensorflow笔记(二)之构造一个简单的神经网络 版权声明:本文为博主原创文章,转载请指明转载地址 http://www.cnblogs.com/fydeblog/p/7425200.html ...
- Spring的quartz定时器重复执行二次的问题解决
Spring的quartz定时器同一时刻重复执行二次的问题解决 最近用Spring的quartz定时器的时候,发现到时间后,任务总是重复执行两次,在tomcat或jboss下都如此. 打印出他们的ha ...
- 调用DATASNAP+FIREDAC的远程方法有时会执行二次SQL或存储过程的BUG(转永喃兄)
调用DATASNAP+FIREDAC的远程方法有时会执行二次SQL或存储过程的BUG 1)查询会重复执行的情形:Result := DATASETPROVIDER.Data会触发它关联的DATASET ...
- 4、TensorFlow基础(二)常用API与变量作用域
1.图.操作和张量 TensorFlow 的计算表现为数据流图,所以 tf.Graph 类中包含一系列表示计算的操作对象(tf.Operation),以及在操作之间流动的数据 — 张量对象(tf.Te ...
- 125、TensorFlow计算图的执行
# TensorFlow使用tf.Session类来表示客户端程序之间的链接 # 虽然一个在其他语言中相似的接口也是可以使用的,列如C++ runtime # 一个tf.Session对象提供了访问本 ...
- 120、TensorFlow创建计算图(二)
#创建一个计算流图 #大多数tensorflow程序开始于dataflow graph 的构造函数 #在这个命令中你执行了tensorflow api的函数 #创建了新的操作tf.Operation ...
随机推荐
- Maven父项目 以SpringBoot项目为例
父项目pom <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http ...
- [Web 前端] 016 css 元素的转换
三种元素之间的转换 display 属性是用来设置元素的类型及隐藏的 常用的属性有 none 元素隐藏且不占位置 block 元素以块元素显示 inline 元素以内联元素显示 inline-bloc ...
- Centos 7下Hadoop分布式集群搭建
一.关闭防火墙(直接用root用户) #关闭防火墙 sudo systemctl stop firewalld.service #关闭开机启动 sudo systemctl disable firew ...
- Mybatis-学习笔记(2)Mybatis配置文件
3>typeAliases:类型别名.2种指定方式. 1>给某个类起个别名 <typeAliases> <typeAlias type="com.lfy.b ...
- .net core 自定义中间件
public class MyMiddleware { //private IConfiguration _configuration; //第一步: private RequestDelegate ...
- QToolButton设置icon的大小
项目中用到了QToolButton上使用图片. 如果在maindow中直接使用QToolButton,如: btnSimulate = new QToolButton; btnSimulate-> ...
- CF912E Prime Gift题解(搜索+二分答案)
CF912E Prime Gift题解(搜索+二分答案) 标签:题解 阅读体验:https://zybuluo.com/Junlier/note/1314956 洛谷题目链接 $ $ CF题目 ...
- Cocos Creator-TypeScript与JS快速过渡
目前的H5游戏开发引擎,国内主流的是Cocos Creator.Laya Box.Egret, 这3种引擎又有各自的开发语言,JavaScript.TypeScript.AS3 . 不同的公司采用的引 ...
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [dx.service.ItemService] found for dependency
在整合ssm框架,测试service层的时候报错 Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: ...
- Scrapy抓取jobbole数据
1.python版本3.6.1 2.python编辑器:JetBrains PyCharm 2.安装virtualenvwrapper-win pip3 install virtualenvwrapp ...