Table of Contents
Shortcuts

# torch.nn.functional.normalize

torch.nn.functional.normalize(input, p=2.0, dim=1, eps=1e-12, out=None)

  Performs L p L_p L p​ normalization of inputs over specified dimension.

  For a tensor `input` of sizes (n 0,...,n d i m,...,n k)(n_0, ..., n_{dim}, ..., n_k)(n 0​,...,n d im​,...,n k​), each n d i m n_{dim}n d im​ -element vector v v v along dimension `dim` is transformed as

  v=v max⁡(∥v∥p,ϵ).v = \frac{v}{\max(\lVert v \rVert_p, \epsilon)}. v=max(∥v∥p​,ϵ)v​.

  With the default arguments it uses the Euclidean norm over vectors along dimension 1 1 1 for normalization.

  Parameters:

    - input (Tensor) – input tensor of any shape

    - p (float) – the exponent value in the norm formulation. Default: 2

    - dim (int or tuple of ints) – the dimension to reduce. Default: 1

    - eps (float) – small value to avoid division by zero. Default: 1e-12

    - out (Tensor, optional) – the output tensor. If `out` is used, this operation won’t be differentiable.

  Return type:

    Tensor

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.