---
title: "GroupNorm"
sidebar_label: "GroupNorm"
description: "The clika_runtime.nn GroupNorm class."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

GroupNorm(num_groups, num_channels, eps=1e-05, affine=True, device=None, dtype=None, *, activation=None)

    Each sample normalizes over each of ``num_groups`` groups of consecutive
    channels and the spatial dimensions of channels-last ``[batch, *spatial,
    num_channels]`` input, the same in training and evaluation.

    Args:
        num_groups: the group count; it divides ``num_channels``.
        num_channels: the channel count of the input.
        eps: added to the variance for numerical stability.
        affine: declare the per-channel ``weight`` (scale) and ``bias``
            (shift) slots.
        device: where the layer's tensors live; ``None`` declares on the cpu.
        dtype: the dtype the layer declares its slots at; ``None`` declares
            the default dtype (:func:`~clika_runtime.get_default_dtype`).
        activation: a fused epilogue applied to every output; ``None`` for
            none.
    

## `__init__`

```python
__init__(self, num_groups: 'int', num_channels: 'int', eps: 'float' = 1e-05, affine: 'bool' = True, device: 'Device | str | None' = None, dtype: 'DtypeLike | None' = None, *, activation: 'ActivationLike' = None) -> 'None'
```

Initialize self.  See help(type(self)) for accurate signature.

## `extra_repr`

```python
extra_repr(self) -> 'str'
```

extra_repr() -> str

One line of per-class detail for :meth:`__repr__`; a layer prints
its geometry here (``in_features=64, out_features=256``).

## `forward`

```python
forward(self, input: 'Tensor') -> 'Tensor'
```

forward(input) -> Tensor

``[batch, *spatial, num_channels]`` to the same shape; the output
dtype follows the input.

## `set_weights`

```python
set_weights(self, weight: 'Tensor', bias: 'Tensor | None' = None) -> 'None'
```

set_weights(weight, bias=None) -> None

Bind the ``[num_channels]`` scale and shift; raises RuntimeError on a
shape mismatch or on a layer made with ``affine=False``.
