Skip to main content

ClikaRT::ops::mean

function

mean()

Tensor mean(
    Tensor x,
    ClikaRT::Span<const std::int64_t> dims = {},
    bool keepdim = false,
    DataType dtype = DataType::Undefined
)

Arithmetic mean of x over dims.

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

Empty dims averages every element. dtype selects the output (and accumulation) dtype; the default keeps x's.

Parameters

  • x: 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 x's dtype.

Returns: the mean tensor; shape = x minus dims.

Throws

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

Declared in ClikaRT/compute/ops.h, line 4291