chainer.functions.normalize(x, eps=1e-05, axis=1)[source]

L2 norm squared (a.k.a. Euclidean norm).

This function implements L2 normalization on a vector along the given axis. No reduction is done along the normalization axis.

In the case when axis=1 and \(x\) is a vector of dimension \((N, K)\), where \(N\) and \(K\) denote mini-batch size and the dimension of the input variable, this function computes an output vector \(y\) by the following equation:

\[y_i = {x_i \over \| x_i \|_2 + \epsilon}\]

eps is used to avoid division by zero when norm of \(x\) along the given axis is zero.

The default value of axis is determined for backward compatibility.

  • x (Variable) – Two dimensional output variable. The first dimension is assumed to be the mini-batch dimension.
  • eps (float) – Epsilon value for numerical stability.
  • axis (int) – Axis along which to normalize.

The output variable which has the same shape as \(x\).

Return type: