# tf.contrib.layers.xavier_initializer

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/layers/python/layers/initializers.py#L31-L57) |

Returns an initializer performing "Xavier" initialization for weights.

#### View aliases


**Main aliases**

\`tf.contrib.layers.xavier_initializer_conv2d\`

<br />

    tf.contrib.layers.xavier_initializer(
        uniform=True, seed=None, dtype=tf.dtypes.float32
    )

This function implements the weight initialization from:

Xavier Glorot and Yoshua Bengio (2010):
[Understanding the difficulty of training deep feedforward neural
networks. International conference on artificial intelligence and
statistics.](http://www.jmlr.org/proceedings/papers/v9/glorot10a/glorot10a.pdf)

This initializer is designed to keep the scale of the gradients roughly the
same in all layers. In uniform distribution this ends up being the range:
`x = sqrt(6. / (in + out)); [-x, x]` and for normal distribution a standard
deviation of `sqrt(2. / (in + out))` is used.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `uniform` | Whether to use uniform or normal distributed random initialization. |
| `seed` | A Python integer. Used to create random seeds. See [`tf.compat.v1.set_random_seed`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/random/set_random_seed) for behavior. |
| `dtype` | The data type. Only floating point types are supported. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| An initializer for a weight matrix. ||

<br />