pysolvegn.build_squared_regularization#
- build_squared_regularization(means, stds, *, weight=1.0, loss=None, loss_scale=1.0, sparse=False)[source]#
Build a squared regularization term based on a Gaussian prior.
The regularization residuals are defined as:
\[r_{\mathrm{reg},i}(\mathbf{p}) = \frac{p_i - \mu_i}{\sigma_i}\]with Jacobian:
\[\begin{split}J_{\mathrm{reg},ij} = \begin{cases} \frac{1}{\sigma_i} & \text{if } i=j \\ 0 & \text{otherwise}. \end{cases}\end{split}\]The resulting
Termcan be directly passed topysolvegn.solve().See also
build_batch_squared_regularization()for the batched version.- Parameters:
means (ArrayLike) – Mean values of the Gaussian prior for each parameter.
stds (ArrayLike) – Standard deviation values of the Gaussian prior for each parameter. All values must be strictly positive.
weight (Real (default=1.0)) – Weight of the regularization term.
loss (Optional[Union[str, Callable]] (default=None)) – Loss function applied to the regularization residuals.
loss_scale (Real (default=1.0)) – Soft threshold of the loss function, in the unit of the residuals (number of standard deviations), see
pysolvegn.Term.sparse (bool (default=False)) – If True, the diagonal Jacobian is a
scipy.sparse.csr_matrix(nentries), otherwise a densenumpy.ndarrayof shape(n, n). Usesparse=Truefor a large number of parameters.
- Returns:
A
Termrepresenting the squared Gaussian regularization.- Return type: