---
title: "ClikaRT::ops::mean"
sidebar_label: "mean"
description: "Arithmetic mean of input over dims. \\[ \\mathrm{out} = \\tfrac{1}{n}\\sum_{i \\in \\text{dims}} x_i \\] Empty dims averages every element."
---

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

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

## mean() {#mean}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`mean`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const std::int64_t>` `dims` `=` `{}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`bool` `keepdim` `=` `false`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`DataType`](../../index.md#DataType) `dtype` `=` [`DataType::Undefined`](../../index.md#DataType)<br />
)

</div>

Arithmetic mean of `input` over `dims`.

$$
\mathrm{out} = \tfrac{1}{n}\sum_{i \in \text{dims}} x_i
$$

Empty `dims` averages every element. [`dtype`](../dtype/index.md) selects the output (and accumulation) dtype; the default keeps `input`'s.

**Parameters**

- `input`: the input tensor.
- `dims`: axes to reduce; empty = all axes.
- `keepdim`: keep reduced axes as size-1 dims; default false.
- `dtype`: output dtype; `Undefined` keeps `input`'s dtype.

**Returns:** the mean tensor; shape = `input` minus `dims`.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) on an out-of-range `dims` entry.

<div class="api-declared">

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

</div>
