SemidefiniteMean
#
SPDEuclideanMean
#
- class hypercoil.init.semidefinite.SPDEuclideanMean(axis: int | Sequence[int] = (0,))[source]#
Batch-wise Euclidean mean of tensors in the positive semidefinite cone.
This is the familiar arithmetic mean:
\(\frac{1}{N}\sum_{i=1}^N X_{i}\)
- Dimension:
- Input : \((N, *, D, D)\)
N denotes batch size,
*
denotes any number of intervening dimensions, D denotes matrix row and column dimension.- Output : \((*, D, D)\)
As above.
- Parameters:
- axisint
Axis or axes over which the mean is computed.
Methods
__call__
(input)Call self as a function.
SPDHarmonicMean
#
- class hypercoil.init.semidefinite.SPDHarmonicMean(axis: int | Sequence[int] = (0,))[source]#
The harmonic mean is computed as the matrix inverse of the Euclidean mean of matrix inverses:
\(\bar{X} = \left(\frac{1}{N}\sum_{i=1}^N X_{i}^{-1}\right)^{-1}\)
- Dimension:
- Input : \((N, *, D, D)\)
N denotes batch size,
*
denotes any number of intervening dimensions, D denotes matrix row and column dimension.- Output : \((*, D, D)\)
As above.
- Parameters:
- axisint
Axis or axes over which the mean is computed.
Methods
__call__
(input)Call self as a function.
SPDLogEuclideanMean
#
- class hypercoil.init.semidefinite.SPDLogEuclideanMean(axis: int | Sequence[int] = (0,), psi: float = 0.0)[source]#
Batch-wise log-Euclidean mean of tensors in the positive semidefinite cone.
The log-Euclidean mean is computed as the matrix exponential of the mean of matrix logarithms.
\(\bar{{X}} = \exp \left(\frac{{1}}{{N}}\sum_{{i=1}}^N \log X_{{i}}\right)\)
- Dimension:
- Input : \((N, *, D, D)\)
N denotes batch size,
*
denotes any number of intervening dimensions, D denotes matrix row and column dimension.- Output : \((*, D, D)\)
As above.
- Parameters:
- axisint
Axis or axes over which the mean is computed. {semidefinite_psi_spec}
Methods
__call__
(input)Call self as a function.
SPDGeometricMean
#
- class hypercoil.init.semidefinite.SPDGeometricMean(axis: int | Sequence[int] = (0,), psi: float = 0.0, eps: float = 1e-05, max_iter: int = 10)[source]#
-
Batch-wise geometric mean of tensors in the positive semidefinite cone.
The geometric mean is computed via gradient descent along the geodesic on the manifold. In brief:
- Initialisation :
The estimate of the mean is initialised to the Euclidean mean.
- Iteration :
Using the working estimate of the mean as the point of tangency, the tensors are projected into a tangent space.
The arithmetic mean of the tensors is computed in tangent space.
This mean is projected back into the positive semidefinite cone using the same point of tangency. It now becomes a new working estimate of the mean and thus a new point of tangency.
- Termination / convergence :
The algorithm terminates either when the Frobenius norm of the difference between the new estimate and the previous estimate is less than a specified threshold, or when a maximum number of iterations has been attained.
- Dimension:
- Input : \((N, *, D, D)\)
N denotes batch size,
*
denotes any number of intervening dimensions, D denotes matrix row and column dimension.- Output : \((*, D, D)\)
As above.
- Parameters:
- axisint
Axis or axes over which the mean is computed.
- psifloat in [0, 1]
Conditioning factor to promote positive definiteness. If this is in (0, 1], the original input will be replaced with a convex combination of the input and an identity matrix.
\(\hat{X} = (1 - \psi) X + \psi I\)
A suitable value can be used to ensure that all eigenvalues are positive and therefore guarantee that the matrix is in the domain of projection operations.
- max_iternonnegative int
The maximum number of iterations of gradient descent to run before termination.
Methods
__call__
(input)Call self as a function.