chainer.functions.normalize

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 matrix of dimension (N,K), where N and K denote mini-batch size and the dimension of the input vectors, this function computes an output matrix y of dimension (N,K) by the following equation:

yi=xi

eps is used to avoid division by zero when norm of \mathbf{x} along the given axis is zero.

The default value of axis is determined for backward compatibility.

Parameters
  • x (Variable or N-dimensional array) – Two dimensional output variable. The first dimension is assumed to be the mini-batch dimension.

  • eps (float) – Epsilon value for numerical stability.

  • axis (int or tuple of ints) – Axis along which to normalize.

Returns

The output variable which has the same shape as x.

Return type

Variable