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.]

最新文章

  1. 深入理解JSX
  2. C# 将绝对路径转换为相对路径
  3. Good-Bye
  4. MMORPG大型游戏设计与开发(part5 of net)
  5. 基于zepto的一个日期区间选择插件
  6. Fast-cgi cgi nginx php-fpm 的关系 (转
  7. JavaScript正则验证邮箱
  8. 杂乱无章之Oracle(一)
  9. 【原】 Spark中Worker源码分析(二)
  10. C#基础知识01(continue、break 和 return、ref 和 out)
  11. MySql5压缩包安装
  12. POJ 2823 Sliding Window 【单调队列】
  13. JAVA转让JS功能
  14. 2018—自学Selenium+Python 笔记(二)
  15. 外网zabbix-server使用主动模式监控公司内网windows服务器
  16. python redis模块详解
  17. Python 判断文件/目录是否存在
  18. Oracle 11g不同情形下的登录分析
  19. Java实现将数字转为大写汉字
  20. c++面向行的输入getline()和get()

热门文章

  1. Vue 基础 day02
  2. [Python3] 009 字符串:给你们看看我的内置方法 第一弹
  3. MYSQL实战-1.mysql基本架构
  4. 【洛谷p1981】表达式求值
  5. [2019杭电多校第四场][hdu6623]Minimal Power of Prime
  6. 使用pdfobject.js实现在线浏览PDF
  7. Linux快速访问多个目录
  8. P4514 上帝造题的七分钟(二维树状数组)
  9. 浏览器是怎样工作的(一):基础知识 转载http://ued.ctrip.com/blog/how-browsers-work-i-basic-knowledge.html
  10. 关于ftp用户连接时出现500OOPS:can not change directory的解决办法