Rate this Page

torch.nn.functional.normalize#

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

Perform Lp normalization of inputs over specified dimension.

For a tensor input of sizes (n0,...,ndim,...,nk), each ndim -element vector v along dimension dim is transformed as

v=max(∥vp,ϵ)v.

With the default arguments it uses the Euclidean norm over vectors along dimension 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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.