# XavierUniform¶

class paddle.nn.initializer. XavierUniform ( fan_in=None, fan_out=None, name=None ) [source]

This class implements the Xavier weight initializer from the paper Understanding the difficulty of training deep feedforward neural networks by Xavier Glorot and Yoshua Bengio.

This initializer is designed to keep the scale of the gradients approximately same in all the layers. In case of Uniform distribution, the range is [-x, x], where

$\begin{split}x = \sqrt{\\frac{6.0}{fan\_in + fan\_out}}\end{split}$
Parameters
• fan_in (float, optional) – fan_in for Xavier initialization, it is inferred from the tensor. The default value is None.

• fan_out (float, optional) – fan_out for Xavier initialization, it is inferred from the tensor. The default value is None.

• name (str, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name.

Returns

A parameter initialized by Xavier weight, using a uniform distribution.

Examples

import paddle

data = paddle.ones(shape=[3, 1, 2], dtype='float32')
name="linear_weight",