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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM