当前位置:网站首页>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]] '''
边栏推荐
- "Xiao Deng's view" the value brought by Siem to enterprises (II)
- After clicking play, the variables in editorwindow will be destroyed inexplicably
- Swin Transformer【Backbone】
- els 注册窗口类、创建窗口类、显示窗口
- 文件操作(一)——文件简介与文件的打开方式和关闭
- Day 7 hcip notes sorting (OSPF configuration)
- STM32 - PWM learning notes
- Unknown-Aware Object Detection:Learning What You Don’t Know from Videos in the Wild(CVPR 2022)
- Cloud native guide what is cloud native infrastructure
- 记一次SQL优化
猜你喜欢

Machine learning foundation plan 0-2: what is machine learning? What does it have to do with AI?

LeetCode·83双周赛·6128.最好的扑克手牌·模拟

多线程编程

Cloud native guide what is cloud native infrastructure

The difference between the world wide web, the Internet and the Internet

Pit trodden when copying list: shallow copy and deep copy

How to install with USB flash disk?

STM32——DMA笔记

Swin Transformer【Backbone】

实现一个方法,找出数组中的第k大和第m大的数字相加之和
随机推荐
[NOIP2001 普及组] 最大公约数和最小公倍数问题
Classic interview questions -- three characteristics of OOP language
[noip2001 popularization group] the problem of maximum common divisor and minimum common multiple
Golang log programming system
QT signal transmission between multi-level objects signal transmission between multi-level nested class objects
LeetCode·每日一题·919.完全二叉树插入器·层次遍历·BFS
Leetcode · daily question · 919. complete binary tree inserter · hierarchy traversal · BFS
els 修改光标、修改图标
Is the galaxy VIP account opened by qiniu safe?
The difference between the world wide web, the Internet and the Internet
[C language] deeply understand integer lifting and arithmetic conversion
Chen Yili, China Academy of communications technology: cost reduction and efficiency increase are the greatest value of Enterprise Cloud native applications
[sql] case expression
记一次SQL优化
File operation (I) -- File introduction and file opening and closing methods
一篇文章让你理解 云原生 容器化相关
Unity quickly builds urban scenes
STM32——串口学习笔记(一个字节、16位数据、字符串、数组)
万维网、因特网和互联网的区别
canvas——矩形的绘制——柱状图的制作