megengine.module.init#
>>> import megengine.module as M
>>> m = M.Conv2d(16, 33, 3, stride=2)
>>> M.init.msra_normal_(m.weight, mode="fan_out", nonlinearity="relu")
备注
良好的初始化策略有助于你的模型在训练时更快地收敛。
Initialization#
将 |
|
使用标量值 0 填入给定 |
|
使用标量值 1 填入给定的 |
|
从均匀分布 \(\mathcal{U}(\text{a}, \text{b})\) 中采样随机值填充给定张量,其中: |
|
从正态分布 \(\mathcal{N}(\text{mean}, \text{std}^2)\) 中采样随机值填充给定 |
|
对于给定的非线性函数返回一个推荐的增益值(见下表)。 |
|
对于给定的权重张量,计算fan_in / fan_out值。 |
|
计算对于给定的权重张量fan_in或fan_out值,这取决于给定的 |
|
使用从 \(\mathcal{U}(-a, a)\) 中随机采样值填入 |
|
从正太分布 \(\mathcal{N}(0, \text{std}^2)\) 中采样随机值填充给定 |
|
从均匀分布 \(\mathcal{U}(-\text{bound}, \text{bound})\) 中采样填充给定 |
|
从正态分布 \(\mathcal{N}(0, \text{std}^2)\) 中采样随机值填充给定张量,其中 |