Skip to main content

ClikaRT::ops::normalize

function

normalize()

Tensor normalize(
    Tensor x,
    Scalar p = 2.0,
    int64_t dim = 1,
    std::optional<double> eps = std::nullopt
)

L_p-normalizes x along dim: each slice is scaled to unit p-norm.

out=xmax(xp,ε)\mathrm{out} = \frac{x}{\max(\lVert x \rVert_p, \varepsilon)}

Parameters

  • x: the input tensor; float dtype.
  • p: the norm degree, an int or float Scalar, kind-preserved; default 2.
  • dim: the axis to normalize along; default 1.
  • eps: divide-by-zero floor; std::nullopt selects 1e-12.

Returns: a new tensor, same shape and dtype as x.

Throws

  • ClikaRT::Error: (INVALID_ARGUMENT) when dim is out of range.

Declared in ClikaRT/compute/ops.h, line 3678