InstanceNorm3D¶

class paddle.nn. InstanceNorm3D ( num_features, epsilon=1e-05, momentum=0.9, weight_attr=None, bias_attr=None, data_format='NCHW', name=None ) [source]

Applies Instance Normalization over a 5D input (a mini-batch of 3D inputs with additional channel dimension) as described in the paper Instance Normalization: The Missing Ingredient for Fast Stylization .

DataLayout: NCHW [batch, in_channels, D, in_height, in_width]

$$input$$ is the input features over a mini-batch.

$\begin{split}\\mu_{\\beta} &\\gets \\frac{1}{HW} \\sum_{i=1}^{HW} x_i \\qquad &//\\ \\ mean\ of\ one\ feature\ map\ in\ mini-batch \\\\ \\sigma_{\\beta}^{2} &\\gets \\frac{1}{HW} \\sum_{i=1}^{HW}(x_i - \\ \\mu_{\\beta})^2 \\qquad &//\ variance\ of\ one\ feature\ map\ in\ mini-batch \\\\ \\hat{x_i} &\\gets \\frac{x_i - \\mu_\\beta} {\\sqrt{\\ \\sigma_{\\beta}^{2} + \\epsilon}} \\qquad &//\ normalize \\\\ y_i &\\gets \\gamma \\hat{x_i} + \\beta \\qquad &//\ scale\ and\ shift\end{split}$

Note

H means height of feature map, W means width of feature map.

Parameters
• num_features (int) – Indicate the number of channels of the input Tensor.

• epsilon (float, optional) – A value added to the denominator for numerical stability. Default is 1e-5.

• momentum (float, optional) – The value used for the moving_mean and moving_var computation. Default: 0.9.

• weight_attr (ParamAttr|bool, optional) – The parameter attribute for Parameter scale of instance_norm. If it is set to None or one attribute of ParamAttr, instance_norm will create ParamAttr as weight_attr, the name of scale can be set in ParamAttr. If the Initializer of the weight_attr is not set, the parameter is initialized one. If it is set to False, will not create weight_attr. Default: None.

• bias_attr (ParamAttr|bool, optional) – The parameter attribute for the bias of instance_norm. If it is set to None or one attribute of ParamAttr, instance_norm will create ParamAttr as bias_attr, the name of bias can be set in ParamAttr. If the Initializer of the bias_attr is not set, the bias is initialized zero. If it is set to False, will not create bias_attr. Default: None.

• data_format (str, optional) – Specify the input data format, could be “NCDHW”. Default: NCDHW.

• name (str, optional) – Name for the InstanceNorm, default is None. For more information, please refer to Name..

Shape:
• x: 5-D tensor with shape: (batch, num_features, dims, height, weight).

• output: 5-D tensor with same shape as input x.

Returns

None.

Examples

import paddle
import numpy as np

np.random.seed(123)
x_data = np.random.random(size=(2, 2, 2, 2, 3)).astype('float32')