# tf.contrib.layers.instance_norm

<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/normalization.py#L42-L169) |

Functional interface for the instance normalization layer.

    tf.contrib.layers.instance_norm(
        inputs, center=True, scale=True, epsilon=1e-06, activation_fn=None,
        param_initializers=None, reuse=None, variables_collections=None,
        outputs_collections=None, trainable=True, data_format=DATA_FORMAT_NHWC,
        scope=None
    )

Reference: <https://arxiv.org/abs/1607.08022>

"Instance Normalization: The Missing Ingredient for Fast Stylization"
Dmitry Ulyanov, Andrea Vedaldi, Victor Lempitsky

<br />

<br />

<br />

| ## Args ||
|---|---|
| `inputs` | A tensor with 2 or more dimensions, where the first dimension has `batch_size`. The normalization is over all but the last dimension if `data_format` is `NHWC` and the second dimension if `data_format` is `NCHW`. |
| `center` | If True, add offset of `beta` to normalized tensor. If False, `beta` is ignored. |
| `scale` | If True, multiply by `gamma`. If False, `gamma` is not used. When the next layer is linear (also e.g. [`nn.relu`](https://www.tensorflow.org/api_docs/python/tf/nn/relu)), this can be disabled since the scaling can be done by the next layer. |
| `epsilon` | Small float added to variance to avoid dividing by zero. |
| `activation_fn` | Activation function, default set to None to skip it and maintain a linear activation. |
| `param_initializers` | Optional initializers for beta, gamma, moving mean and moving variance. |
| `reuse` | Whether or not the layer and its variables should be reused. To be able to reuse the layer scope must be given. |
| `variables_collections` | Optional collections for the variables. |
| `outputs_collections` | Collections to add the outputs. |
| `trainable` | If `True` also add variables to the graph collection `GraphKeys.TRAINABLE_VARIABLES` (see [`tf.Variable`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/Variable)). |
| `data_format` | A string. `NHWC` (default) and `NCHW` are supported. |
| `scope` | Optional scope for `variable_scope`. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `Tensor` representing the output of the operation. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If `data_format` is neither `NHWC` nor `NCHW`. |
| `ValueError` | If the rank of `inputs` is undefined. |
| `ValueError` | If rank or channels dimension of `inputs` is undefined. |

<br />