# tf.compat.v1.uniform_unit_scaling_initializer

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/ops/init_ops.py#L673-L738) |

Initializer that generates tensors without scaling variance.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.initializers.uniform_unit_scaling`](https://www.tensorflow.org/api_docs/python/tf/compat/v1/uniform_unit_scaling_initializer)

<br />

    tf.compat.v1.uniform_unit_scaling_initializer(
        factor=1.0,
        seed=None,
        dtype=https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/dtypes#float32
    )

When initializing a deep network, it is in principle advantageous to keep
the scale of the input variance constant, so it does not explode or diminish
by reaching the final layer. If the input is `x` and the operation `x * W`,
and we want to initialize `W` uniformly at random, we need to pick `W` from

    [-sqrt(3) / sqrt(dim), sqrt(3) / sqrt(dim)]

to keep the scale intact, where `dim = W.shape[0]` (the size of the input).
A similar calculation for convolutional networks gives an analogous result
with `dim` equal to the product of the first 3 dimensions. When
nonlinearities are present, we need to multiply this by a constant `factor`.
See (Sussillo et al., 2014) for deeper motivation, experiments
and the calculation of constants. In section 2.3 there, the constants were
numerically computed: for a linear layer it's 1.0, relu: \~1.43, tanh: \~1.15.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `factor` | Float. A multiplicative factor by which the values will be scaled. |
| `seed` | A Python integer. Used to create random seeds. See [`tf.compat.v1.set_random_seed`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/compat/v1/set_random_seed) for behavior. |
| `dtype` | Default data type, used if no `dtype` argument is provided when calling the initializer. Only floating point types are supported. |

<br />

<br />

<br />

<br />

| ## References ||
|---|---|
| [Sussillo et al., 2014](https://arxiv.org/abs/1412.6558) ([pdf](http://arxiv.org/pdf/1412.6558.pdf)) ||

<br />

## Methods

### `from_config`

[View source](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/ops/init_ops.py#L75-L94)

    @classmethod
    from_config(
        config
    )

Instantiates an initializer from a configuration dictionary.

#### Example:

    initializer = RandomUniform(-1, 1)
    config = initializer.get_config()
    initializer = RandomUniform.from_config(config)

<br />

<br />

<br />

| Args ||
|---|---|
| `config` | A Python dictionary. It will typically be the output of `get_config`. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| An Initializer instance. ||

<br />

### `get_config`

[View source](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/ops/init_ops.py#L737-L738)

    get_config()

Returns the configuration of the initializer as a JSON-serializable dict.

<br />

<br />

<br />

| Returns ||
|---|---|
| A JSON-serializable Python dict. ||

<br />

### `__call__`

[View source](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/ops/init_ops.py#L718-L735)

    __call__(
        shape, dtype=None, partition_info=None
    )

Returns a tensor object initialized as specified by the initializer.

<br />

<br />

<br />

| Args ||
|---|---|
| `shape` | Shape of the tensor. |
| `dtype` | Optional dtype of the tensor. If not provided use the initializer dtype. |
| `partition_info` | Optional information about the possible partitioning of a tensor. |

<br />