# BatchNormInference¶

BatchNormInference  // Adjust input for mean and variance


## Description¶

### Inputs¶

Name Element Type Shape
input real $$(\bullet, C, \ldots)$$
gamma same as input $$(C)$$
beta same as input $$(C)$$
mean same as input $$(C)$$
variances same as input $$(C)$$

### Attributes¶

Name Type Notes
epsilon double Small bias added to variance to avoid division by 0.

### Outputs¶

Name Element Type Shape
normalized same as gamma Same as input

## Mathematical Definition¶

The axes of the input fall into two categories: positional and channel, with channel being axis 1. For each position, there are $$C$$ channel values, each normalized independently.

Normalization of a channel sample is controlled by two values:

• the mean $$\mu$$, and
• the variance $$\sigma^2$$;

and by two scaling attributes: $$\gamma$$ and $$\beta$$.

$\mathtt{normalized}_{\bullet, c, \ldots} = \frac{\mathtt{input}_{\bullet, c, \ldots}-\mu_c}{\sqrt{\sigma^2_c+\epsilon}}\gamma_c+\beta_c$

## C++ Interface¶

class BatchNormInference : public ngraph::op::Op

Public Functions

const std::string &description() const

Get the string name for the type of the node, such as Add or Multiply. The class name, must not contain spaces as it is used for codegen.

Return
A const reference to the node’s type name

BatchNormInference(const Output<Node> &input, const Output<Node> &gamma, const Output<Node> &beta, const Output<Node> &mean, const Output<Node> &variance, double epsilon)

Parameters
• input: [., C, …]
• gamma: gamma scaling for normalized value. [C]
• beta: bias added to the scaled normalized value [C]
• mean: value for mean normalization [C]
• variance: value for variance normalization [C]
• epsilon: Avoids divsion by 0 if input has 0 variance

BatchNormInference(double eps, const Output<Node> &gamma, const Output<Node> &beta, const Output<Node> &input, const Output<Node> &mean, const Output<Node> &variance)

In this version of BatchNorm:

MEAN AND VARIANCE: provided by the ‘mean’ and ‘variance’ parameters.

OUTPUT VALUE: a single tensor with the normalized value of ‘input’.

AUTODIFF SUPPORT:

• ’generate_adjoints(…) may throw an exception.

SHAPE DETAILS: gamma: must have rank 1, with the same span as input’s channel axis. beta: must have rank 1, with the same span as input’s channel axis. input: must have rank >= 2. The second dimension represents the channel axis and must have a span of at least 1. mean: must have rank 1, with the same span as input’s channel axis. variance: must have rank 1, with the same span as input’s channel axis. output: shall have the same shape as ‘input’.

void validate_and_infer_types()

Throws if the node is invalid.