127、TensorFlow 计算图执行(二)
2024-08-28 17:46:52
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.]
最新文章
- 深入理解JSX
- C# 将绝对路径转换为相对路径
- Good-Bye
- MMORPG大型游戏设计与开发(part5 of net)
- 基于zepto的一个日期区间选择插件
- Fast-cgi cgi nginx php-fpm 的关系 (转
- JavaScript正则验证邮箱
- 杂乱无章之Oracle(一)
- 【原】 Spark中Worker源码分析(二)
- C#基础知识01(continue、break 和 return、ref 和 out)
- MySql5压缩包安装
- POJ 2823 Sliding Window 【单调队列】
- JAVA转让JS功能
- 2018—自学Selenium+Python 笔记(二)
- 外网zabbix-server使用主动模式监控公司内网windows服务器
- python redis模块详解
- Python 判断文件/目录是否存在
- Oracle 11g不同情形下的登录分析
- Java实现将数字转为大写汉字
- c++面向行的输入getline()和get()
热门文章
- Vue 基础 day02
- [Python3] 009 字符串:给你们看看我的内置方法 第一弹
- MYSQL实战-1.mysql基本架构
- 【洛谷p1981】表达式求值
- [2019杭电多校第四场][hdu6623]Minimal Power of Prime
- 使用pdfobject.js实现在线浏览PDF
- Linux快速访问多个目录
- P4514 上帝造题的七分钟(二维树状数组)
- 浏览器是怎样工作的(一):基础知识 转载http://ued.ctrip.com/blog/how-browsers-work-i-basic-knowledge.html
- 关于ftp用户连接时出现500OOPS:can not change directory的解决办法