autoarray.inversion.regularization.Constant#
- class Constant[source]#
Bases:
AbstractRegularizationRegularization which uses the neighbors of the mesh (e.g. shared Delaunay vertexes) and a single value to smooth an inversion’s solution.
For this regularization scheme, there is only 1 regularization coefficient that is applied to all neighboring pixels / parameters. This means that the matrix B only needs to regularize pixels / parameters in one direction (e.g. pixel 0 regularizes pixel 1, but NOT visa versa). For example:
- B = [-1, 1] [0->1]
[0, -1] 1 does not regularization with 0
A small numerical value of 1.0e-8 is added to all elements in constant regularization matrix, to ensure that it is positive definite.
A full description of regularization and this matrix can be found in the parent AbstractRegularization class.
JAX & gradient support (2026-07 gradient sweep): on meshes with an analytic neighbor structure (the rectangular family) this scheme is JAX-differentiable and FD-certified. On the Delaunay mesh family (
Delaunay,DelaunayNN,KNearestNeighbor,KNNBarycentric) the neighbors come from a directscipy.spatial.Delaunaycall on the traced source-plane mesh grid, so it raisesTracerArrayConversionErrorunderjax.jit/jax.grad— use a split-family scheme (e.g.ConstantSplit) there instead.- Parameters:
coefficient (
float) – The regularization coefficient which controls the degree of smooth of the inversion reconstruction.
Methods
log_det_regularization_matrix_term_fromReturns
log det Hof this scheme's regularization matrix computed from a factorization the scheme itself knows about, orNonewhen no such shortcut exists (the default).Returns the regularization matrix with shape [pixels, pixels].
regularization_term_fromReturns this scheme's contribution to the regularization term
s^T H scomputed from a factorization the scheme itself knows about, orNonewhen no such shortcut exists (the default).Returns the regularization weights of this regularization scheme.
Attributes
Whether this scheme's regularization matrix
Hhas the constant vector as an exact null mode by construction, i.e. it is the precision matrix of an intrinsic Gaussian prior that penalizes only differences between pixels and leaves the overall level of the reconstruction unconstrained.is_split_regularizationWhether this scheme is a "split" regularization variant, which regularizes using a split-cross calculation of the mesh's mappings rather than the mappings themselves.
- has_constant_null_mode = True#
Whether this scheme’s regularization matrix
Hhas the constant vector as an exact null mode by construction, i.e. it is the precision matrix of an intrinsic Gaussian prior that penalizes only differences between pixels and leaves the overall level of the reconstruction unconstrained.This holds for the smoothness schemes whose every row of
Bsums to zero (Constant,ConstantSplit,Adapt,AdaptPower,AdaptSplit,AdaptSplitPower); theirHis singular except for the small diagonal jitter added for numerical stability. It does not hold for schemes with a zeroth-order term or a kernel covariance, whoseHis positive-definite in its own right.When
Truethe Bayesian evidence normalises the prior with the pseudo-determinant ofH(the product of its non-zero eigenvalues) rather than its determinant, which would be set by the arbitrary jitter and carry its rounding noise (PyAutoArray#682): seeAbstractInversion.log_det_regularization_matrix_term. A unit test pins this flag to the measured spectrum of every scheme, so it must only be set where the null mode is exact.
- regularization_weights_from(linear_obj, xp=<module 'numpy' from '/home/docs/checkouts/pyautolens/envs/latest/lib/python3.12/site-packages/numpy/__init__.py'>)[source]#
Returns the regularization weights of this regularization scheme.
The regularization weights define the level of regularization applied to each parameter in the linear object (e.g. the
pixelsin aMapper).For standard regularization (e.g.
Constant) are weights are equal, however for adaptive schemes (e.g.Adapt) they vary to adapt to the data being reconstructed.- Parameters:
linear_obj (
LinearObj) – The linear object (e.g. aMapper) which uses these weights when performing regularization.- Returns:
The regularization weights.
- regularization_matrix_from(linear_obj, xp=<module 'numpy' from '/home/docs/checkouts/pyautolens/envs/latest/lib/python3.12/site-packages/numpy/__init__.py'>)[source]#
Returns the regularization matrix with shape [pixels, pixels].
- Parameters:
linear_obj (
LinearObj) – The linear object (e.g. aMapper) which uses this matrix to perform regularization.- Returns:
The regularization matrix.