data_norm

paddle.fluid.layers.data_norm(input, act=None, epsilon=1e-05, param_attr=None, data_layout='NCHW', in_place=False, name=None, moving_mean_name=None, moving_variance_name=None, do_model_average_for_mean_and_var=True)[source]

Data Normalization Layer

This op can be used as a normalizer function for conv2d and fully_connected operations. The required data format for this layer is one of the following:

  1. NHWC [batch, in_height, in_width, in_channels]

  2. NCHW [batch, in_channels, in_height, in_width]

\(input\) is the input features over a mini-batch.

\[\begin{split}\mu_{\beta} &\gets \frac{1}{m} \sum_{i=1}^{m} x_i \qquad &//\ \ mini-batch\ mean \\ \sigma_{\beta}^{2} &\gets \frac{1}{m} \sum_{i=1}^{m}(x_i - \ \mu_{\beta})^2 \qquad &//\ mini-batch\ variance \\ \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}\]
Parameters
  • input (variable) – The input variable which is a LoDTensor.

  • act (string, Default None) – Activation type, linear|relu|prelu|…

  • epsilon (float, Default 1e-05) –

  • param_attr (ParamAttr) – The parameter attribute for Parameter scale.

  • data_layout (string, default NCHW) – NCHW|NHWC

  • in_place (bool, Default False) – Make the input and output of batch norm reuse memory.

  • name (string, Default None) – A name for this layer(optional). If set None, the layer will be named automatically.

  • moving_mean_name (string, Default None) – The name of moving_mean which store the global Mean.

  • moving_variance_name (string, Default None) – The name of the moving_variance which store the global Variance.

  • do_model_average_for_mean_and_var (bool, Default True) – Whether parameter mean and variance should do model average when model average is enabled.

Returns

A tensor variable which is the result after applying data normalization on the input.

Return type

Variable

Examples

import paddle.fluid as fluid

hidden1 = fluid.data(name="hidden1", shape=[64, 200])
hidden2 = fluid.layers.data_norm(name="hidden2", input=hidden1)