nn.init 中实现的初始化函数 uniform, normal, const, Xavier, He initialization

torch.init https://pytorch.org/docs/stable/nn.html#torch-nn-init

1. 均匀分布

torch.nn.init.uniform_(tensor, a=0, b=1)
服从~U(a,b)U(a, b)U(a,b)

2. 正太分布

torch.nn.init.normal_(tensor, mean=0, std=1)
服从~N(mean,std)N(mean, std)N(mean,std)

3. 初始化为常数

torch.nn.init.constant_(tensor, val)
初始化整个矩阵为常数val

4. Xavier

基本思想是通过网络层时,输入和输出的方差相同,包括前向传播和后向传播,相关论文:Understanding the difficulty of training deep feedforward neural networks

其它具体参考:https://blog.csdn.net/dss_dssssd/article/details/83959474

原文地址:https://www.cnblogs.com/tingtin/p/13544711.html