---
title: "ClikaRT::ops::group_norm"
sidebar_label: "group_norm"
description: "Group normalization: channels split into num_groups groups, normalized per group (channels-last)."
---

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

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

## group\_norm() {#group_norm}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`group_norm`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`int64_t` `num_groups`,<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>

Group normalization: channels split into `num_groups` groups, normalized per group (channels-last).

Statistics are computed per `(sample, group)` over the group's channels and the spatial dims; with `running_mean` / `running_var` present they are folded per channel instead (batch-norm style). Optional fused `activation` applies to the result.

**Parameters**

- `input`: the input, `[N, *spatial, C]`.
- `num_groups`: number of channel groups; must divide `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 `num_groups` does not divide the channel count or an operand is mis-shaped.

<div class="api-declared">

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

</div>
