[PyTorch]PyTorch中模型的参数初始化的几种方法(转)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
转载请注明出处:
http://www.cnblogs.com/darkknightzh/p/8297793.html
参考网址:
http://pytorch.org/docs/0.3.0/nn.html?highlight=kaiming#torch.nn.init.kaiming_normal
https://github.com/prlz77/ResNeXt.pytorch/blob/master/models/model.py
https://github.com/facebookresearch/ResNeXt/blob/master/models/resnext.lua
https://github.com/bamos/densenet.pytorch/blob/master/densenet.py
https://github.com/szagoruyko/wide-residual-networks/blob/master/models/utils.lua
说明:暂时就这么多吧,错误之处请见谅。前两个初始化的方法见pytorch官方文档
1. xavier初始化
torch.nn.init.xavier_uniform(tensor, gain=1)
对于输入的tensor或者变量,通过论文Understanding the difficulty of training deep feedforward neural networks” - Glorot, X. & Bengio, Y. (2010)的方法初始化数据。初始化服从均匀分布U(−a,a)U(−a,a),其中a=gain×2/(fan_in+fan_out)−−−−−−−−