TF随笔-3
>>> import tensorflow as tf
>>> node1 = tf.constant(3.0, dtype=tf.float32)
>>> node2 = tf.constant(4.0)
>>> node3=tf.constant(66)
>>> print(node1,node2,node3)
(<tf.Tensor 'Const:0' shape=() dtype=float32>, <tf.Tensor 'Const_1:0' shape=() dtype=float32>, <tf.Tensor 'Const_2:0' shape=() dtype=int32>)
>>> node4=tf.constant(77,dtype=tf.int32)
>>> print(node1,node2,node3,node4)
(<tf.Tensor 'Const:0' shape=() dtype=float32>, <tf.Tensor 'Const_1:0' shape=() dtype=float32>, <tf.Tensor 'Const_2:0' shape=() dtype=int32>, <tf.Tensor 'Const_3:0' shape=() dtype=int32>)
>>> sess = tf.Session()
2017-07-05 22:24:06.991688: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-05 22:24:06.991783: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-05 22:24:06.991820: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-07-05 22:24:06.991837: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-05 22:24:06.991850: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
>>> print(sess.run([node1, node2]))
[3.0, 4.0]
1、使用tf.constant函数,创建常数
可以指定常数类型,也可以隐式指定。
2、下面的语句输出常数对象
print(node1,node2,node3)
3、创建session,并生成计算图,然后,调用run方法
输出node1和node2的计算
print(sess.run([node1, node2]))print(sess.run([node1, node2]*(node1+node2)))
[ 21. 28.]
TF随笔-3的更多相关文章
- TF随笔-13
import tensorflow as tf a=tf.constant(5) b=tf.constant(3) res1=tf.divide(a,b) res2=tf.div(a,b) with ...
- TF随笔-11
#!/usr/bin/env python2 # -*- coding: utf-8 -*- import tensorflow as tf my_var=tf.Variable(0.) step=t ...
- TF随笔-10
#!/usr/bin/env python# -*- coding: utf-8 -*-import tensorflow as tf x = tf.constant(2)y = tf.constan ...
- TF随笔-9
计算累加 #!/usr/bin/env python2 # -*- coding: utf-8 -*-"""Created on Mon Jul 24 08:25:41 ...
- TF随笔-8
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Mon Jul 10 09:35:04 201 ...
- TF随笔-7
求平均值的函数 reduce_mean axis为1表示求行 axis为0表示求列 >>> xxx=tf.constant([[1., 10.],[3.,30.]])>> ...
- tf随笔-6
import tensorflow as tfx=tf.constant([-0.2,0.5,43.98,-23.1,26.58])y=tf.clip_by_value(x,1e-10,1.0)ses ...
- tf随笔-5
# -*- coding: utf-8 -*-import tensorflow as tfw1=tf.Variable(tf.random_normal([2,6],stddev=1))w2=tf. ...
- TF随笔-4
>>> import tensorflow as tf>>> a=tf.constant([[1,2],[3,4]])>>> b=tf.const ...
随机推荐
- MiniUI级联
OnCellCommitEdit: function (e) { var grid = e.sender; var record = e.record; ...
- oracle 创建视图、修改视图、删除视图、利用视图操作基本表
转:http://blog.sina.com.cn/s/blog_6b58d2fa0100rgvw.html 1.使用create or replace view命令创建视图 语法格式: create ...
- jmeter之报告和分析
转载:http://www.cnblogs.com/miaomiaokaixin/p/6118081.html jmeter -n -t 脚本名字.jmx -l xxx.jtl -e -o 指定目录( ...
- JavaScript判断对象 是什么类型的.
// 这种方法不起作用 if (x == undefined) { // 作某些操作 } // 这个方法同样不起作用- if (typeof(x) == undefined) { // 作某些 ...
- Json日期格式 转化为 YYYY-MM-DD-hh-mm-ss
function timeStamp2String(time) { var datetime = new Date(); datetime.setTime(time); var year = date ...
- Sybase:游标用法以及嵌套用法
Sybase:游标用法以及嵌套用法 游标示例一: --Sybase游标示例一: create PROCEDURE DBA.p_proc_test() ON EXCEPTION RESUME begin ...
- Apache 错误整理
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localho ...
- CSS 3 中的多列属性
.column-count <!DOCTYPE html> <html> <head> <meta charset="utf-8"> ...
- python的正则表达式捕获组命名问题
- Cnblog页面美化小记
Cnblog页面美化小记 这两天我在网上翻找了许许多多的资料,打开了不计其数的博客,对着\(js\).\(html\).\(css\)等文件删删改改,在浏览器和\(vscode\)间辗转腾挪...总算 ...