KaimingUniform

class paddle.nn.initializer. KaimingUniform ( fan_in=None ) [source]

Implements the Kaiming Uniform initializer

This class implements the weight initialization from the paper Delving Deep into Rectifiers: Surpassing Human-Level Performance on ImageNet Classification by Kaiming He, Xiangyu Zhang, Shaoqing Ren and Jian Sun. This is a robust initialization method that particularly considers the rectifier nonlinearities.

In case of Uniform distribution, the range is [-x, x], where

\[\begin{split}x = \sqrt{\\frac{6.0}{fan\_in}}\end{split}\]
Parameters
  • fan_in (float32|None) – fan_in for Kaiming uniform Initializer. If None, it is

  • None. (inferred from the variable. default is) –

Note

It is recommended to set fan_in to None for most cases.

Examples

import paddle
import paddle.nn as nn

linear = nn.Linear(2,
                   4,
                   weight_attr=nn.initializer.KaimingUniform())
data = paddle.rand([30, 10, 2], dtype='float32')
res = linear(data)