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 ...
随机推荐
- [转]如何用C#动态编译、执行代码
在开始之前,先熟悉几个类及部分属性.方法:CSharpCodeProvider.ICodeCompiler.CompilerParameters.CompilerResults.Assembly. 一 ...
- Part1.1 、RabbitMQ 操作使用
本节目录: 一.最基本的生产者消费者二.acknowledgment 消息不丢失的方法. 三.durable 消息不丢失 (消息持久化) 四.消息获取顺序 RabbitMQ安装. (1.1).ce ...
- 解释一下python中的关系运算符
关系运算符用于比较两个值 1.小于号,如果左边的值较小,则返回Trueprint('hi'<'Hi')#False 2.大于号,如果左边的值较大,则返回Trueprint(1.1+2.2> ...
- Win10 IIS 安装.net 4.5
更新Win10,原来的IIS站点访问不了,原因是因为IIS 没有.net 4.5,使用网上的aspnet_regiis.exe -i命令,一点都不靠谱,直接提示: C:\WINDOWS\system3 ...
- 《Spring Boot 实战》随记
第一部分 Spring 4.x 1. Spring基础 略过 2. Spring常用配置 2.1 Bean的scope 使用@Scope注解配置scope.默认signleton,原型模式protot ...
- maven自动化构建deploy
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...
- 并查集模板 && 带权并查集模板
不带权: ]; void init(void) { ;i<=n;i++) f[i]=i; } int fd(int x) { return f[x]==x?x:fd[x]=fd(f[x]); } ...
- linux例行性工作调度学习(一)
Linux系统中有一种例行性工作(crontab)可以调度,是通过crontab和at来实现的. 这两种工作调度: 一种是例行性的,就是每隔一定的周期要来办的事项. 一种是突发性的,就是这次做完以后就 ...
- clipbrd剪切板查看器
本文,我们来学习一下简单的概念,即,如何查看系统剪贴版里面有什么内容? 如果要想看.或者验证系统剪贴版里面都有什么内容,最为简单的方法就是通过"粘贴"的操作来验证! 但是, ...
- 0927-转载:SSM:spring+springmvc+mybatis框架中的XML配置文件功能详细解释
这篇文章暂时只对框架中所要用到的配置文件进行解释说明,而且是针对注解形式的,框架运转的具体流程过两天再进行总结. spring+springmvc+mybatis框架中用到了三个XML配置文件:web ...