当前位置:网站首页>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]] '''
边栏推荐
猜你喜欢

How to install with USB flash disk?

STM32——DMA笔记

Canvas -- draw text -- modification of pie chart
![[Yuri crack man] brings you easy understanding - deep copy and shallow copy](/img/26/b7330c7f5fdac55c8f5e9fa24658ee.png)
[Yuri crack man] brings you easy understanding - deep copy and shallow copy

Pit trodden when copying list: shallow copy and deep copy

文件操作(一)——文件简介与文件的打开方式和关闭

Use eventlog analyzer for log forensics analysis

Win11 hide input method status bar method
![[untitled]](/img/6f/a2cd98af7a8de469e5311422b48afe.png)
[untitled]

Functions and usage of snownlp Library
随机推荐
The source of everything, the choice of code branching strategy
Multithreaded programming
[translation] cloud like internal load balancer for kubernetes?
使用anaconda配置gpu版本的tensorflow(30系列以下显卡)
Remember SQL optimization once
(9) Attribute introspection
Autojs cloud control source code + display
Opening method of win11 microphone permission
Course notes of single chip microcomputer principle and interface technology for migrant workers majoring in electronic information engineering
Opencv error: (parameter or structure field)) unrecognized or unsupported array type in functon 'cvgetmat‘
YOLOv3: An Incremental Improvement
[noip2001 popularization group] the problem of maximum common divisor and minimum common multiple
[SQL] CASE表达式
.net serialize enumeration as string
Canvas -- draw text -- modification of pie chart
els 修改光标、修改图标
Use eventlog analyzer for log forensics analysis
How to close the case prompt icon of win11? Closing method of win11 case prompt Icon
Golang log programming system
Type the URL to the web page display. What happened during this period?