> 文章列表 > nn.init.xavier_uniform_()的作用:根据均匀分布生成Tensor

nn.init.xavier_uniform_()的作用:根据均匀分布生成Tensor

nn.init.xavier_uniform_()的作用:根据均匀分布生成Tensor

官网解释如下:
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)


nn.init.xavier_uniform_()的作用:根据均匀分布生成Tensor

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