Skip to main content

vector_normalize

Function vector_normalize 

Source
pub fn vector_normalize<const D: usize, E: ElementConversion>(
    x: Tensor<D>,
    norm: impl Into<Norm>,
    dim: impl AsIndex,
    eps: E,
) -> Tensor<D>
Expand description

Normalize a tensor versus its vector_norm.

Equivalent to x.clone() / vector_norm(x, norm, dim).clamp_min(eps).

§Arguments

  • x - The input tensor.
  • norm - The selected norm.
  • dim - The dimension to compute the norm over. Negative dimensions are supported and count from the end.
  • eps - The epsilon for the norm.

§Returns

The normalized tensor.