autoarray.inversion.regularization.AdaptPower#
- class AdaptPower[source]#
Bases:
AdaptRegularization which uses the neighbors of the mesh (e.g. shared Delaunay vertexes) and values adapted to the data being fitted to smooth an inversion’s solution, with the coefficient convention of
Constant.This is the corrected sibling of
Adapt. It reconstructs the same adaptive weighting – high smoothing where there is no signal, less where there is (Nightingale, Dye and Massey 2018) – but fixes the two ways in whichAdaptdiverges fromConstant:The coefficient enters at ``lambda^2``, not ``lambda^4``.
Adaptsquares its coefficients twice (once when interpolating them into per-pixel weights, once in the matrix builder), so its matrix scales as the fourth power of the coefficient. This class raises the interpolated coefficient topowerbefore the builder squares it, so the effective exponent is2 * powerand the defaultpower=1.0matchesConstant. Under the sharedLogUniform(1e-6, 1e6)prior that means the prior now spanslambda^2, and the regularization matrix stays positive-definite toc ~ 1e6rather than collapsing fromc ~ 1e4– the fragility that produced the likelihood-overflow floods seen in free-coefficient adaptive fits.Every mesh edge is scattered once.
Adaptadds each ordered neighbor pair to both the(i, j)and(j, i)entries, and the neighbor list already holds each unordered edge twice, so its matrix is exactly2 xConstant’s. This class usesweighted_regularization_matrix_single_scatter_from, which scatters each ordered pair once with the symmetric edge weight0.5 * (w_i ** 2 + w_j ** 2)– a weighted graph Laplacian, so still symmetric and positive semi-definite.
Together these make
AdaptPower(inner_coefficient=c, outer_coefficient=c)exactly equal toConstant(coefficient=c)for anyc, which is whatAdapt’s docstring always claimed and never delivered.A full description of regularization and this matrix can be found in the parent
AbstractRegularizationclass; theBmatrix construction is described onAdapt.Migration from ``Adapt``. The coefficient scale is squared:
c_new = c_old ** 2. To reproduce the legacy class exactly, passpower=2.0– but note the factor-2 scatter is fixed regardless, soAdaptPower(power=2.0)is0.5 xAdaptwith the same coefficients.JAX & gradient support: as for
Adapt– JAX-differentiable and FD-certified on the rectangular mesh family, but raisingTracerArrayConversionErroron the Delaunay mesh family, whose neighbors come from a direct scipy call on the traced mesh grid (useAdaptSplitPowerthere).- Parameters:
inner_coefficient (
float) – The inner regularization coefficient which controls the degree of smoothing of the inversion reconstruction in the inner (high signal) regions of a mesh’s reconstruction.outer_coefficient (
float) – The outer regularization coefficient which controls the degree of smoothing of the inversion reconstruction in the outer (low signal) regions of a mesh’s reconstruction.signal_scale (
float) – A factor which controls how rapidly the smoothness of regularization varies from high signal regions to low signal regions.power (
float) – The exponent the interpolated coefficient is raised to before the matrix builder squares it, so the coefficient enters the regularization matrix at the power2 * power. The default1.0is theConstantconvention;2.0is the legacyAdaptconvention. This is a convention switch, not a model parameter – the shipped prior config fixes it as aConstantprior so a search never samples it.
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
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.
- regularization_weights_from(linear_obj, xp=<module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/pyautolens/envs/latest/lib/python3.12/site-packages/numpy/__init__.py'>)[source]#
Returns the regularization weights of this regularization scheme.
These are the interpolated inner / outer coefficients raised to
self.power(default1.0), as opposed toAdapt, which squares them.- Parameters:
linear_obj (
LinearObj) – The linear object (e.g. aMapper) which uses these weights when performing regularization.- Return type:
The regularization weights.
- regularization_matrix_from(linear_obj, xp=<module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/pyautolens/envs/latest/lib/python3.12/site-packages/numpy/__init__.py'>)[source]#
Returns the regularization matrix with shape [pixels, pixels].
Every mesh edge is scattered once (unlike
Adapt), so uniform weights reproduceConstantexactly.- Parameters:
linear_obj (
LinearObj) – The linear object (e.g. aMapper) which uses this matrix to perform regularization.- Return type:
The regularization matrix.