Skip to main content

ClikaRT::ops::batch_norm

function

batch_norm()

Tensor batch_norm(
    Tensor x,
    OptionalTensor weight = {},
    OptionalTensor bias = {},
    OptionalTensor running_mean = {},
    OptionalTensor running_var = {},
    std::optional<double> eps = std::nullopt,
    std::optional<Activation> activation = std::nullopt
)

Per-channel batch normalization (inference form), channels-last.

out=xμcσc2+εγc+βc\mathrm{out} = \frac{x - \mu_c}{\sqrt{\sigma_c^2 + \varepsilon}} \cdot \gamma_c + \beta_c

x is [N, *spatial, C]; every operand is per-channel [C]. The supplied running_mean / running_var ARE the statistics (inference only; no training mode, no momentum). Optional fused activation applies to the result.

Parameters

  • x: the input, [N, *spatial, C].
  • weight: optional per-channel scale [C].
  • bias: optional per-channel shift [C].
  • running_mean: per-channel mean [C].
  • running_var: per-channel variance [C].
  • eps: stability floor; std::nullopt selects 1e-5.
  • activation: optional fused activation; absent = none.

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

Throws

  • ClikaRT::Error: (INVALID_ARGUMENT) when a per-channel operand does not match C.

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