megengine.module.init.calculate_gain#
- calculate_gain(nonlinearity, param=None)[source]#
Returns a recommended gain value (see the table below) for the given nonlinearity function.
nonlinearity
gain
Linear / Identity
\(1\)
Conv{1,2,3}D
\(1\)
Sigmoid
\(1\)
Tanh
\(\frac{5}{3}\)
ReLU
\(\sqrt{2}\)
Leaky Relu
\(\sqrt{\frac{2}{1 + {\text{negative}_\text{slope}}^2}}\)