scimba_torch.numerical_solvers.preconditioner_projector¶
Preconditioner projectors and their components.
Classes
|
Anagram preconditioner projector. |
Energy natural gradient preconditioner projector. |
|
|
Abstract base class for matrix-based preconditioner projectors. |
- class MatrixPreconditionerProjector(space, pde=None, **kwargs)[source]¶
Bases:
AbstractPreconditionerAbstract base class for matrix-based preconditioner projectors.
This class provides a structure for implementing preconditioners that use a matrix to precondition the gradients in projection problems.
- Parameters:
space (
AbstractApproxSpace) – The approximation space where the projection takes place.**kwargs – Additional keyword arguments for configuring the preconditioner.
- abstract compute_preconditioning_matrix(*args, **kwargs)[source]¶
Computes the preconditioning matrix.
- Parameters:
*args (
LabelTensor) – Input tensors for computing the preconditioning matrix.**kwargs – Additional keyword arguments.
- Return type:
Tensor- Returns:
The computed preconditioning matrix.
- get_preconditioning_matrix(data, **kwargs)[source]¶
Retrieves the preconditioning matrix based on the input data.
- Parameters:
data (
tuple[LabelTensor,...]) – The input data for computing the preconditioning matrix.**kwargs – Additional keyword arguments.
- Return type:
Tensor- Returns:
The preconditioning matrix.
- get_preconditioning_matrix_bc(data, **kwargs)[source]¶
Retrieves the BC preconditioning matrix based on the input data.
- Parameters:
data (
tuple) – The input data for computing the boundary condition preconditioning matrix.**kwargs – Additional keyword arguments.
- Return type:
Tensor- Returns:
The boundary condition preconditioning matrix.
- class EnergyNaturalGradientPreconditionerProjector(space, **kwargs)[source]¶
Bases:
MatrixPreconditionerProjectorEnergy natural gradient preconditioner projector.
This class implements a preconditioner using the energy natural gradient method.
- Parameters:
space (
AbstractApproxSpace) – The approximation space where the projection takes place.**kwargs – Additional keyword arguments for configuring the preconditioner.
- Keyword Arguments:
matrix_regularization (
float) – Regularization parameter for the preconditioning matrix (default: 1e-6).adaptive_matrix_regularization (
bool, default=False)training (If True, adaptively adjusts the regularization parameter during)
Levenberg-Marquardt). ((à la)
parameter (If False, uses the fixed regularization)
matrix_regularization. (specified by)
adaptive_matrix_regularization_increase (
float, default=10.0)search (Factor by which to decrease the regularization parameter if the line)
size. (quickly succeeds in finding a suitable step)
adaptive_matrix_regularization_decrease (
float, default=0.5)search
size.
adaptive_matrix_regularization_min (
float, default=1e-12)adjustment. (Minimum value for the regularization parameter when using adaptive)
use_lstsq (bool) – Whether to use least squares solver for
(default (computing the preconditioner) – True).
inversion. (If False, uses direct matrix)
- metric_matrix(*args, **kwargs)[source]¶
Computes the metric matrix for the given input tensors.
- Parameters:
*args (
LabelTensor) – Input tensors for computing the metric matrix.**kwargs – Additional keyword arguments.
- Return type:
Tensor- Returns:
The computed metric matrix.
- compute_preconditioning_matrix(*args, **kwargs)[source]¶
Computes the preconditioning matrix using the metric matrix.
- Parameters:
*args (
LabelTensor) – Input tensors for computing the preconditioning matrix.**kwargs – Additional keyword arguments.
- Return type:
Tensor- Returns:
The computed preconditioning matrix.
- update_matrix_regularization(n_steps, loss_has_decreased)[source]¶
Updates the regularization parameter for the preconditioning matrix.
This method adaptively adjusts the regularization parameter during training based on the number of line search steps taken and whether the loss has decreased.
- Parameters:
n_steps (
int) – The number of line search steps taken.loss_has_decreased (
bool) – Whether the loss has decreased after the line search.
- class AnagramPreconditionerProjector(space, **kwargs)[source]¶
Bases:
MatrixPreconditionerProjectorAnagram preconditioner projector.
This class implements a preconditioner using the Anagram method.
- Parameters:
space (
AbstractApproxSpace) – The approximation space where the projection takes place.**kwargs – Additional keyword arguments for configuring the preconditioner.
- Keyword Arguments:
svd_threshold (
float) – Threshold for singular value decomposition (default: 1e-6).
- compute_preconditioning_matrix(*args, **kwargs)[source]¶
Computes the preconditioning matrix using the Jacobian of the space.
- Parameters:
*args (
LabelTensor) – Input tensors for computing the preconditioning matrix.**kwargs – Additional keyword arguments.
- Return type:
Tensor- Returns:
The computed preconditioning matrix.
- assemble_right_member(data, res_l, res_r)[source]¶
Assembles the right member for the preconditioning.
- Parameters:
data (
tuple) – The input data for assembling the right member.res_l (
tuple) – The left residuals.res_r (
tuple) – The right residuals.
- Return type:
Tensor- Returns:
The assembled right member.