Skip to main content

ClikaRT::ops::instance_norm

function

instance_norm()

Tensor instance_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
)

Instance normalization: statistics per (sample, channel) over the spatial dims (channels-last).

With running_mean / running_var present they are folded instead of computing per-instance statistics (inference form; no training mode). 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: optional precomputed per-channel mean [C].
  • running_var: optional precomputed 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 3634