magni.cs.reconstruction.amp.stop_criterion module

Module providing stop criteria for the Approximate Message Passing (AMP) algorithm.

Routine listings

ValidatedStopCriterion(magni.utils.validation.types.StopCriterion)
A base class for validated magni.cs.reconstruction.amp stop criteria.
MSEConvergence(ValidatedStopCriterion)
A mean square error (MSE) convergence stop criterion.
NormalisedMSEConvergence(ValidatedStopCriterion)
A normalised mean squaure error (NMSE) convergence stop criterion.
Residual(ValidatedStopCriterion)
A residual based stop criterion.
ResidualMeasurementsRatio(ValidatedStopCriterion)
A residual-measurements-ratio based stop criterion.
class magni.cs.reconstruction.amp.stop_criterion.ValidatedStopCriterion(var)[source]

Bases: magni.utils.validation.types.StopCriterion

A base class for validated magni.cs.reconstruction.amp stop criteria.

Parameters:var (dict) – The stop criterion state variables.
compute(var)[source]

Compute the stop criterion value.

Parameters:var (dict) – The variables used in computing of the stop criterion value.
Returns:
  • stop (bool) – The indicator of whether or not the stop criterion is satisfied.
  • value (float) – The stop criterion value.

Notes

This method honors magni.utils.validation.enable_allow_validate_once.

class magni.cs.reconstruction.amp.stop_criterion.MSEConvergence(var)[source]

Bases: magni.cs.reconstruction.amp.stop_criterion.ValidatedStopCriterion

A mean square error (MSE) convergence stop criterion.

Parameters:var (dict) – The stop criterion state variables.

Notes

The following state variables are used in this stop criterion:

  • A
  • tolerance

Examples

For example,

>>> import numpy as np
>>> from magni.cs.reconstruction.amp.stop_criterion import MSEConvergence
>>> state = {'tolerance': 1e-3, 'A': np.ones((10,10))}
>>> variables = {'alpha_bar_prev': np.ones((10, 1)),
... 'alpha_bar': np.arange(10).reshape(10, 1)}
>>> MSE = MSEConvergence(state)
>>> stop, val = MSE.compute(variables)
>>> stop
False
>>> np.round(val, 2)
20.5
compute(var)[source]

Compute the MSE convergence stop criterion value.

The AMP algorithm should converge to a fixed point. This criterion is based on the mean squared error of the difference between the proposed solution in this iteration and the proposed solution in the previous solution.

Parameters:var (dict) – Dictionary of variables used in calculating of the stop criterion.
Returns:
  • stop (bool) – The indicator of whether or not the stop criterion is satisfied.
  • value (float) – The stop criterion value.
class magni.cs.reconstruction.amp.stop_criterion.NormalisedMSEConvergence(var)[source]

Bases: magni.cs.reconstruction.amp.stop_criterion.ValidatedStopCriterion

A normalised mean squaure error (NMSE) convergence stop criterion.

Parameters:var (dict) – The stop criterion state variables.

Notes

The following state variables are used in this stop criterion:

  • tolerance

Examples

For example,

>>> import numpy as np
>>> from magni.cs.reconstruction.amp.stop_criterion import (
... NormalisedMSEConvergence)
>>> state = {'tolerance': 1e-3}
>>> variables = {'alpha_bar_prev': np.ones((10, 1)),
... 'alpha_bar': np.arange(10).reshape(10, 1)}
>>> NMSE = NormalisedMSEConvergence(state)
>>> stop, val = NMSE.compute(variables)
>>> stop
False
>>> np.round(val, 2)
20.5
compute(var)[source]

Compute the normalised MSE convergence stop criterion value.

The AMP algorithm should converge to a fixed point. This criterion is based on the mean squared error of the difference between the proposed solution in this iteration and the proposed solution in the previous solution normalised by the mean squared error of the proposed solution in the previous iteration.

Parameters:var (dict) – Dictionary of variables used in calculating of the stop criterion.
Returns:
  • stop (bool) – The indicator of whether or not the stop criterion is satisfied.
  • value (float) – The stop criterion value.
class magni.cs.reconstruction.amp.stop_criterion.Residual(var)[source]

Bases: magni.cs.reconstruction.amp.stop_criterion.ValidatedStopCriterion

A residual based stop criterion.

Parameters:var (dict) – The stop criterion state variables.

Notes

The following state variables are used in this stop criterion:

  • y
  • tolerance
  • A

Examples

For example,

>>> import numpy as np
>>> from magni.cs.reconstruction.amp.stop_criterion import Residual
>>> state = {'tolerance': 1e-3, 'y': np.ones((10, 1)),
... 'A': np.ones((10,10))}
>>> variables = {'A_dot_alpha_bar': np.arange(10).reshape(10, 1)}
>>> Res = Residual(state)
>>> stop, val = Res.compute(variables)
>>> stop
False
>>> np.round(val, 2)
20.5
compute(var)[source]

Compute the residual stop criterion value.

If the noise level is (approximately) known, the AMP iterations may be stopped once the residual is on the order of the noise level. This stopping criterion is based on the mean sqaured error of the residual.

Parameters:var (dict) – Dictionary of variables used in calculating of the stop criterion.
Returns:
  • stop (bool) – The indicator of whether or not the stop criterion is satisfied.
  • value (float) – The stop criterion value.
class magni.cs.reconstruction.amp.stop_criterion.ResidualMeasurementsRatio(var)[source]

Bases: magni.cs.reconstruction.amp.stop_criterion.ValidatedStopCriterion

A residual-measurements-ratio based stop criterion.

Parameters:var (dict) – The stop criterion state variables.

Notes

The following state variables are used in this stop criterion:

  • y
  • tolerance

Examples

For example,

>>> import numpy as np
>>> from magni.cs.reconstruction.amp.stop_criterion import (
... ResidualMeasurementsRatio)
>>> state = {'tolerance': 1e-3, 'y': np.ones((10, 1))}
>>> variables = {'A_dot_alpha_bar': np.arange(10).reshape(10, 1)}
>>> ResMeasRat = ResidualMeasurementsRatio(state)
>>> stop, val = ResMeasRat.compute(variables)
>>> stop
False
>>> np.round(val, 2)
14.32
compute(var)[source]

Compute the residual-measurements-ratio stop criterion value.

If the noise level is (approximately) known, the AMP iterations may be stopped once the residual is on the order of the noise level. This stopping criterion is based on ratio of the mean sqaured error of the residual to the mean squared error of the measurements.

Parameters:var (dict) – Dictionary of variables used in calculating of the stop criterion.
Returns:
  • stop (bool) – The indicator of whether or not the stop criterion is satisfied.
  • value (float) – The stop criterion value.