calculate_gain¶
- paddle.nn.initializer. calculate_gain ( nonlinearity, param=None ) [source]
- 
         Get the recommended gainvalue of some nonlinearity function.gainvalue can be used in somepaddle.nn.initializerapi to adjust the initialization value.- Parameters
- 
           - nonlinearity (str) – name of nonlinearity activation function. If it is a linear function, such as: linear/conv1d/conv2d/conv3d/conv1d_transpose/conv2d_transpose/conv3d_transpose , 1.0 will be returned. 
- param (bool|int|float, optional) – optional parameter for somme nonlinearity function. Now, it only applies to ‘leaky_relu’. Default: None, it will be calculated as 0.01 in the formula. 
 
- Returns
- 
           A float value, which is the recommended gain for this nonlinearity function. 
 Examples import paddle gain = paddle.nn.initializer.calculate_gain('tanh') # 5.0 / 3 gain = paddle.nn.initializer.calculate_gain('leaky_relu', param=1.0) # 1.0 = math.sqrt(2.0 / (1+param^2)) initializer = paddle.nn.initializer.Orthogonal(gain) 
