当前位置:网站首页>tf.truncated_normal()用法
tf.truncated_normal()用法
2022-07-26 03:10:00 【phac123】
简述
tf.truncated_normal(shape, mean=0.0, stddev=1.0,
dtype=tf.float32, seed=None, name=None)
- 这个函数产生正态分布;这是一个截断的产生正态分布的函数,生成的数值服从具有指定平均值和标准偏差的正态分布,换句话说,产生的值如果与均值的差值大于两倍的标准差则丢弃重新选择;这个函数和一般的正态分布产生的随机数据相比,这个函数产生的随机数与均值的差距不会超过两倍的标准差,但是一般的别的函数是可能的。
- shape:表示生成张量的维度
- mean:均值
- stddev:标准差
- dtype:输出的类型
- seed:一个整数,当设置之后,每次生成的随机数都一样
- name:操作的名字
此外:在正态分布的曲线中:
横轴区间(μ-σ,μ+σ)内的面积为68.268949%
横轴区间(μ-2σ,μ+2σ)内的面积为95.449974%
横轴区间(μ-3σ,μ+3σ)内的面积为99.730020%
X落在(μ-3σ,μ+3σ)以外的概率小于千分之三,在实际问题中常认为相应的事件是不会发生的,基本上可以把区间(μ-3σ,μ+3σ)看作是随机变量X实际可能的取值区间,这称之为正态分布的"3σ"原则.
在tf.truncated_normal中如果X的取值在区间(μ-2σ,μ+2σ)之外则重新进行选择.这样保证了生成的值都在均值附近.
实例
import tensorflow._api.v2.compat.v1 as tf
tf.disable_v2_behavior()
c = tf.truncated_normal(shape = [3,3],mean = 0 , stddev = 1)
with tf.Session() as sess:
print(sess.run(c))
输出:
''' [[-0.04338798 0.9103105 -1.0928041 ] [ 0.1483252 -0.11247149 -1.2393879 ] [ 0.5323354 0.946114 -0.66076565]] '''
边栏推荐
- 小测(一)
- OxyCon 2022 网络抓取前沿大会即将开启!
- Functions and usage of snownlp Library
- FPGA_ Initial use process of vivado software_ Ultra detailed
- 【C语言】深入理解 整型提升 和 算术转换
- els 窗口设置、WM_CREATE、WM_PAINT
- Golang log programming system
- After clicking play, the variables in editorwindow will be destroyed inexplicably
- Implement a method to find the sum of the number k and m in the array
- Safety margin of mass consumption
猜你喜欢

如何用U盘进行装机?

Implement a method to find the sum of the number k and m in the array
![[sql] case expression](/img/05/1bbb0b5099443f7ce5f5511703477e.png)
[sql] case expression

"Xiao Deng's view" the value brought by Siem to enterprises (II)

File operation (I) -- File introduction and file opening and closing methods

STM——EXTI外部中断学习笔记

中国信通院陈屹力:降本增效是企业云原生应用的最大价值

复制列表时踩过的坑:浅拷贝与深拷贝

班级里有一群学生考试结果出来了,考了语文和数学两门,请筛选出总分是第一的同学

There are a group of students in the class who have got the test results in Chinese and mathematics. Please select the students whose total score is the first
随机推荐
Multithreaded programming
一切的源头,代码分支策略的选择
Leetcode · 83 biweekly match · 6128. best poker hand · simulation
经典面试问题——OOP语言的三大特征
【无标题】
els 注册窗口类、创建窗口类、显示窗口
实现一个方法,找出数组中的第k大和第m大的数字相加之和
[NOIP2001 普及组]装箱问题
Nahamcon CTF 2022 babyrev reverse analysis
规范自己debug的流程
【尤里复裂人】带你轻松理解——深拷贝和浅拷贝
Golang 中‘...‘的用法
Use eventlog analyzer for log forensics analysis
重装Win7系统如何进行?
[NOIP2001 普及组] 最大公约数和最小公倍数问题
【TensorFlow&PyTorch】图像数据增强API
复制列表时踩过的坑:浅拷贝与深拷贝
一篇文章让你理解 云原生 容器化相关
Continuous delivery and Devops are good friends
[sql] case expression