官网解释如下:
Signature: nn.init.xavier_uniform_(tensor: torch.Tensor, gain: float = 1.0) -> torch.Tensor
Docstring:
Fills the input Tensor with values according to the method
described in Understanding the difficulty of training deep feedforward neural networks - Glorot, X. & Bengio, Y. (2010), using a uniform
distribution. The resulting tensor will have values sampled from
:math:\mathcal{U}(-a, a) where
… math::
a = \text{gain} \times \sqrt{\frac{6}{\text{fan_in} + \text{fan_out}}}
Also known as Glorot initialization.
Args:
tensor: an n-dimensional torch.Tensor
gain: an optional scaling factor
Examples:
>>> w = torch.empty(3, 5)
>>> nn.init.xavier_uniform_(w, gain=nn.init.calculate_gain(‘relu’))
File: c:\users\administrator\appdata\roaming\python\python37\site-packages\torch\nn\init.py
Type: function
其中
U
=
(
−
a
,
a
)
\mathcal{U}=(-\mathrm{a}, \mathrm{a})
U=(−a,a)

参见:
Glorot, X. & Bengio, Y. (2010). Understanding the difficulty of training deep feedforward neural networks.








![[chapter27][PyTorch][visdom]](https://img-blog.csdnimg.cn/597538cecfca46c88d8ef38aedd7137e.png)





![[ChatGPT]-02-ChatGPT对安全的影响和开源的LLM大模型资源汇总](https://img-blog.csdnimg.cn/img_convert/e8d576407b15ab14ac0d90a042f49c5b.jpeg)


