mean

mean#

Compute the mean of the reduction dimensions

template<typename InType, int D>
__MATX_INLINE__ auto matx::mean(const InType &in, const int (&dims)[D])#

Calculate the mean of values in an operator along axes

Performs a sum reduction from tensor “in”, followed by a division by the number of elements in the reduction. Similar to the reduce function, the type of reduction is dependent on the rank of the output tensor. A single value denotes a reduction over the entire input, a 1D tensor denotes a reduction over each row independently, etc.

Template Parameters:
  • InType – Input data type

  • D – Num of dimensions to reduce over

Parameters:
  • in – Input data to reduce

  • dims – Array containing dimensions to reduce over

Returns:

Operator with reduced values of mean-reduce computed

template<typename InType>
__MATX_INLINE__ auto matx::mean(const InType &in)#

Calculate the mean of values in an operator

Performs a sum reduction from operator, followed by a division by the number of elements in the reduction. Similar to the reduce function, the type of reduction is dependent on the rank of the output tensor. A single value denotes a reduction over the entire input, a 1D tensor denotes a reduction over each row independently, etc.

Template Parameters:

InType – Input data type

Parameters:

in – Input data to reduce

Returns:

Operator with reduced values of mean-reduce computed

Examples#

auto t0 = make_tensor<TestType>({});
auto t4 = ones<TestType>({30, 40, 50, 60});    
// Compute the mean over all dimensions in "t4" and store the result in "t0"
(t0 = mean(t4)).run(exec);