---
title: "ClikaRT::ops::instance_norm"
sidebar_label: "instance_norm"
description: "Instance normalization: statistics per (sample, channel) over the spatial dims (channels-last)."
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--function">function</span>

## instance\_norm() {#instance_norm}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`instance_norm`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`OptionalTensor`](../../index.md#OptionalTensor) `weight` `=` `{}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`OptionalTensor`](../../index.md#OptionalTensor) `bias` `=` `{}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`OptionalTensor`](../../index.md#OptionalTensor) `running_mean` `=` `{}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`OptionalTensor`](../../index.md#OptionalTensor) `running_var` `=` `{}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::optional<double>` `eps` `=` `std::nullopt`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::optional<`[`Activation`](./index.md#Activation)`>` `activation` `=` `std::nullopt`<br />
)

</div>

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**

- `input`: 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 `input`.

**Throws**

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

<div class="api-declared">

Declared in `ClikaRT/compute/ops.h`, line 3731

</div>
