AI学习之路(11): 创建随机张量1
来源:互联网 发布:windows.old可以删吗 编辑:程序博客网 时间:2024/06/04 18:12
由于在测试的过程中,经常要产生一些不同分布的随机数,比如初始化待定的变量。又或者一些训练数据。因此来学习一些随机数的产生。
tf.random_normal(shape, mean=0.0, stddev=1.0, dtype=tf.float32, seed=None, name=None)
从正态分布创建随机张量。
参数:
shape: 一维整数张量或者Python数组
mean: 常数,表示正态分布的系数。
stddev: 常数,表示正态分布绝对偏差。
dtype: 输出张量的类型。
seed: Python整数,用来产生随机的种子。
name: 张量的名称。
返回值:
使用随机数据填充指定行列的张量。
例子:
#python 3.5.3 蔡军生 #http://edu.csdn.net/course/detail/2592 #import tensorflow as tfimport matplotlib as mplimport matplotlib.pyplot as plt#绘制直方图def drawHist(heights): #创建直方图 #第一个参数为待绘制的定量数据,不同于定性数据,这里并没有事先进行频数统计 #第二个参数为划分的区间个数 plt.hist(heights, 100) plt.xlabel('Value') plt.ylabel('Frequency') plt.title('Test') plt.show() #创建张量常量x = tf.random_normal(shape=[20000],mean=0.0, stddev=1.0,dtype=tf.float32)#显示它的值init_op = tf.global_variables_initializer()with tf.Session() as sess: sess.run(init_op) print(x.eval()) drawHist(x.eval())
输出结果:
1. C++标准模板库从入门到精通
http://edu.csdn.net/course/detail/3324
2.跟老菜鸟学C++
http://edu.csdn.net/course/detail/2901
3. 跟老菜鸟学python
http://edu.csdn.net/course/detail/2592
4. 在VC2015里学会使用tinyxml库
http://edu.csdn.net/course/detail/2590
5. 在Windows下SVN的版本管理与实战
http://edu.csdn.net/course/detail/2579
6.Visual Studio 2015开发C++程序的基本使用
http://edu.csdn.net/course/detail/2570
7.在VC2015里使用protobuf协议
http://edu.csdn.net/course/detail/2582
8.在VC2015里学会使用MySQL数据库
http://edu.csdn.net/course/detail/2672
0 0
- AI学习之路(11): 创建随机张量1
- AI学习之路(12): 创建随机张量2
- AI学习之路(13): 创建随机张量3
- AI学习之路(9): 张量的常量1
- AI学习之路(8): 定义张量变量
- AI学习之路(10): 张量的常量2
- AI学习之路(14): 张量的平方计算
- AI学习之路(15): 张量不同数轴的平均值计算
- pytorch学习笔记(1)--pytorch张量
- Unity人工智能学习—确定性AI算法之随机运动
- AI学习之路(1):TensorFlow在Windows安装
- AI学习之路(16): TensorFlow优化器1
- AI学习之路(一)
- AI学习之路(3): 牛刀小试之线性回归
- AI学习之路(4): TensorFlow是什么
- AI学习之路(5): NumPy是什么
- AI学习之路(6): NumPy的使用
- AI学习之路(7): 生成训练数据
- Java for Web学习笔记(三八):自定义tag(6)一些注意
- Docker Toolbox 镜像源站
- JavaScript高级程序设计[美]Nicholas C.Zakas著 读书笔记(一)
- jsp+servlet实现最基本的注册登陆功能
- 生成订单编号
- AI学习之路(11): 创建随机张量1
- AOP切入同类调用方法-AopContext.currentProxy()
- px,pt,ppi,dpi,dp,sp,em,rem,vw和vh等css中常用长度之间区别总结
- R studio server 使用中的问题及解决
- 前端学习(2):为document的click事件指定一个事件句柄函数(考虑跨浏览器兼容问题)
- 杂文
- <10>python学习笔记——os模块 / os.path模块
- 正则表达式
- 258. Add Digits