当前位置:网站首页>xavier_ normal_ Initialization test
xavier_ normal_ Initialization test
2022-07-24 06:57:00 【qq_ six hundred and fifty-two million five hundred and thirty t】
Reference resources Deep feedforward network and Xavier Initialization principle - You know (zhihu.com)
xavier_normal_ initialization , Input in hypothesis x The mean of 0 Under the circumstances , Output can be maintained y With the input x The variance of is constant , Test with code
import torch
def get_linear(vavier=False):
linear = torch.nn.Linear(300, 400)
if vavier:
torch.nn.init.xavier_normal_(linear.weight)
torch.nn.init.kaiming_uniform_()
return linear
def get_x():
x = 9 * torch.randn(300, 300)
return x
if __name__ == '__main__':
x = get_x()
linear = get_linear(True)
linear2 = get_linear()
relu = torch.nn.ReLU()
print(f" Raw input x The mean for {x.mean()}, The variance of {x.var()}")
# print(f"linear layer w The mean for {linear.weight.mean()}, The variance of {linear.weight.var()}")
x_out = linear(x)
x_out2 = linear2(x)
print(f"x after xavier initialization linear After the layer w The mean for {x_out.mean()}, The variance of {x_out.var()}")
print(f"x after kaiming initialization linear After the layer w The mean for {x_out2.mean()}, The variance of {x_out2.var()}")
x_out = relu(x_out)
x_out2 = relu(x_out2)
print(f"x after xavier,relu After the layer w The mean for {x_out.mean()}, The variance of {x_out.var()}")
print(f"x after kaiming,relu After the layer w The mean for {x_out2.mean()}, The variance of {x_out2.var()}")
边栏推荐
- Redis数据类型-String(字符串类型)
- You don't have to waste your life on others' standards
- Redis特殊数据类型-GEO
- Thinking of data analysis -- analyzing the retail industry as a whole -- an all-round and multifaceted detailed analysis
- Redis special data type Geo
- [lvgl] API functions for setting, changing and deleting styles of components
- Special effects - click with the mouse and the fireworks will burst
- xavier_normal_ 初始化测试
- 自己的人生无须浪费在别人的标准中
- Introduction to kubernetes (kubernetes benefits)
猜你喜欢

Directory and file management

Redis.conf详解

数据分析思维之从整体出发分析零售行业——全方位多方面细节分析
![[lvgl layout] grid layout](/img/36/47f586f3dc1a114ed7775c4e190872.png)
[lvgl layout] grid layout
![[audio decoding chip] Application of vs1503 audio decoding chip](/img/ee/0d5f95fba647592cc95f1e9f410bc9.png)
[audio decoding chip] Application of vs1503 audio decoding chip

OSS authorizes a single bucket permission

【C语言】操作符详解(深入理解+整理归类)

MapReduce (I)

STM32 ADC based on Hal library uses DMA multi-channel sampling and solves the problems encountered

【学习笔记】Web页面渲染的流程
随机推荐
一个AI玩41个游戏,谷歌最新多游戏决策Transformer综合表现分是DQN的两倍
你就是你,没有人可以取代
(笔记整理未完成)【图论:求单源最短路径】
Redis basic type - ordered set Zset
不要太在意别人对你的看法
sojson jsjiami.com.v6 爬虫js逆向
Special effects - return to the top (kitten effects)
Special effects - cobweb background effects
Redis特殊数据类型-GEO
[lvgl (1)] a brief introduction to lvgl
Record the pits encountered in the deserialization of phpserializer tool class
Random forest, lgbm parameter adjustment based on Bayesian Optimization
PostgreSQL date handler usage
JMeter distributed pressure measurement
OSS authorizes a single bucket permission
Redis special data type bitmap
Mac can't connect to local MySQL server through socket '/tmp/mysql Sock '(2) problem
Love yourself first, then others.
创建WPF项目
Esp32 ultra detailed learning record: NTP synchronization time