Skip to content

variance of a Tensor

Submitted by wil..@..il.com

Assigned to Nobody

Link to original bugzilla bug (#1773)
Version: 3.5 (future version)
Operating system: Linux

Description

Hi
As today there are :

  • a Tensor::mean() method to compute the mean of a tensor on a given dim, apriori just calling the MeanReducer :
    template <typename Dims> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
    const TensorReductionOp<internal::MeanReducer<CoeffReturnType>, const Dims, const Derived>
    mean(const Dims& dims) const {
    return TensorReductionOp<internal::MeanReducer<CoeffReturnType>, const Dims, const Derived>(derived(), dims, internal::MeanReducer<CoeffReturnType>());
    }

  • some reducers in TensorFunctors.h
    https://eigen.tuxfamily.org/dox-devel/unsupported/TensorFunctors_8h_source.html

but no native way to compute the variance of a Tensor.

I see some variance computation in TF but does nt seem to use Eigen:
https://github.com/tensorflow/tensorflow/tree/a062a8c1f6a89c88a908813add05a0bfd5d523b9/tensorflow/core/lib/histogram

One way would be first call the mean reducer and then computing manually the var by looping manually over all coeffs but not taking advantages of packets.
For the end user, it would perhaps be better to add a Tensor::var() method or at least a VarReducer callable by calling reduce(dim, reducer).

Would it be acceptable to add a VarReducer in TensorFunctors ?
Kind

Edited by Eigen Bugzilla