TF随笔-4
>>> import tensorflow as tf
>>> a=tf.constant([[1,2],[3,4]])
>>> b=tf.constant([6,6])
>>> result=tf.add(a,b)
>>> sess=tf.Session()
>>> sess.run(result)
array([[ 7, 8],
[ 9, 10]], dtype=int32)
>>> c=tf.constant([[1,2,3],[4,5,6]])
>>> result3=a*b
>>> sess.run(result3)
array([[ 6, 12],
[18, 24]], dtype=int32)>>> x1=tf.constant([[1,2],[3,4]],name="x1")
>>> x1=tf.constant([[1,2],[3,4]],name="x1")
>>> x2=tf.constant([[11,22],[33,44]],name="x2")
>>> y=tf.matmul(x1,x2)
>>> sess.run(y)
array([[ 77, 110],
[165, 242]], dtype=int32)
>>> x3=tf.constant([[10,20],],name="x3")
>>> z=tf.matmul(x3,x1)
>>> sess.run(z)
array([[ 70, 100]], dtype=int32)
#正太分布
>>> n1=tf.random_normal([2,3],mean=5,stddev=2)
#正太分布,随机值偏离平均值超过2个标准差,会重新生成新的随机数,避免产生统计学上的异常数据。
>>> n2=tf.truncated_normal([2,3],mean=6,stddev=1)
#平均分布
>>> n3=tf.random_uniform([2,3],minval=5,maxval=20)
#gamma分布
>>> n4=tf.random_gamma([2,3],alpha=1.5,beta=2.9)
>>> sess.run(n1)
array([[ 1.70361972, 0.65788937, 7.08583546],
[ 5.49968147, 2.47537422, 7.47936249]], dtype=float32)
>>> sess.run(n2)
array([[ 5.51383209, 5.28713369, 5.9794035 ],
[ 5.45024824, 6.65198326, 4.69569492]], dtype=float32)
>>> sess.run(n3)
array([[ 9.39581871, 13.13985538, 17.50672722],
[ 10.08992577, 15.1558075 , 18.60567093]], dtype=float32)
>>> sess.run(n4)
array([[ 0.3365562 , 0.27886772, 0.8982302 ],
[ 0.21223408, 0.95498532, 1.72396851]], dtype=float32)
>>> n5=tf.Variable(tf.random_normal([2,3],mean=8,stddev=2))
>>> m1=tf.zeros([2,2],tf.int32)
>>> m2=tf.ones([2,2],tf.float32)
>>> m3=tf.fill([2,2],66)
>>> sess.run(m1)
array([[0, 0],
[0, 0]], dtype=int32)
>>> sess.run(m2)
array([[ 1., 1.],
[ 1., 1.]], dtype=float32)
>>> sess.run(m3)
array([[66, 66],
[66, 66]], dtype=int32)
TF随笔-4的更多相关文章
- 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随笔-3
>>> import tensorflow as tf>>> node1 = tf.constant(3.0, dtype=tf.float32)>>& ...
随机推荐
- django-ORM复习补充
建表 class Author(models.Model): name = models.CharField(max_length=32) age = models.IntegerField() # ...
- OpenFileDialog.Filter 属性
如果 Filter 属性为 Empty,将显示所有文件. 始终显示文件夹. Filter 由以下部分组成:筛选器说明,后跟竖线 (|) 和筛选模式. 筛选器可以指定一个或多个文件类型. 说明描述了对话 ...
- HDOJ 1238 Substrings 【最长公共子串】
HDOJ 1238 Substrings [最长公共子串] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
- Android LCD
Android LCD(一):LCD基本原理篇Android LCD(二):LCD常用接口原理篇Android LCD(三):Samsung LCD接口篇Android LCD(四):LCD驱动调试篇
- ASP.NET MVC jQuery 树插件在项目中使用方法(一)
jsTree是一个 基于jQuery的Tree控件.支持XML,JSON,Html三种数据源.提供创建,重命名,移动,删除,拖"放节点操作.可以自己自定义创建,删 除,嵌套,重命名,选择节点 ...
- 20145201《Java程序设计》第五次实验报告
实验五 Java网络编程及安全 实验内容 1.掌握Socket程序的编写: 2.掌握密码技术的使用: 3.设计安全传输系统. 我负责客户端 组队队员:鄢曼君20145227负责服务器 博客地址:htt ...
- MyCat分片集群
数据库集群会产生的问题: 自增ID问题 数据关联查询问题(水平拆分) 数据同步问题 数据库集群 自动增长id产生重复的话,解决: UUID形式 (没有排序 不是自增) 设置数据库步长 其他方案: r ...
- G1垃圾回收器参数配置
下面是完整的 G1 的 GC 开关参数列表. 选项/默认值 说明 -XX:+UseG1GC 使用 G1 (Garbage First) 垃圾收集器 -XX:MaxGCPauseMillis=n 设置最 ...
- JDBC插入性能优化对比
今天对Insert进行了性能测试,结果反差很大,平时都是单条插入,虽然性能要求没有那么高,但是突然在项目中,人家给定时间内完成,这就尴尬了. 优化数据库,优化服务器,优化代码,反正通过各种优化提高数据 ...
- linux安装-----源码安装步骤--zlib软件安装
该zlib 可以对许多其他软件的编译代码起着优化 压缩作用. 解压压缩包: .tar.gz------------->tar zxvf 压缩包.tar.gz .tar.bz2---------- ...