---
title: "ClikaRT::ops::batch_norm"
sidebar_label: "batch_norm"
description: "Per-channel batch normalization (inference form), channels-last."
---

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

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

## batch\_norm() {#batch_norm}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`batch_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>

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

$$
\mathrm{out} = \frac{x - \mu_c}{\sqrt{\sigma_c^2 + \varepsilon}}
    \cdot \gamma_c + \beta_c
$$

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

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

</div>
