pydvl.influence.torch.preconditioner
¶
Preconditioner
¶
Bases: ABC
Abstract base class for implementing pre-conditioners for improving the convergence of CG for systems of the form
i.e. a matrix \(M\) such that \(M^{-1}(A + \lambda \operatorname{I})\) has a better condition number than \(A + \lambda \operatorname{I}\).
fit
¶
Implement this to fit the pre-conditioner to the matrix represented by the mat_mat_prod Args: operator: The preconditioner is fitted to this operator regularization: regularization parameter \(\lambda\) in the equation $ ( A + \lambda \operatorname{I})x = \operatorname{rhs} $ Returns: self
Source code in src/pydvl/influence/torch/preconditioner.py
solve
¶
solve(rhs: Tensor)
Solve the equation \(M@Z = \operatorname{rhs}\) Args: rhs: right hand side of the equation, corresponds to the residuum vector (or matrix) in the conjugate gradient method
RETURNS | DESCRIPTION |
---|---|
solution \(M^{-1}\operatorname{rhs}\) |
Source code in src/pydvl/influence/torch/preconditioner.py
to
abstractmethod
¶
to(device: device) -> Preconditioner
Implement this to move the (potentially fitted) preconditioner to a specific device
JacobiPreconditioner
¶
JacobiPreconditioner(num_samples_estimator: int = 1)
Bases: Preconditioner
Pre-conditioner for improving the convergence of CG for systems of the form
The JacobiPreConditioner uses the diagonal information of the matrix \(A\). The diagonal elements are not computed directly but estimated via Hutchinson's estimator.
where \(u_i\) are i.i.d. Gaussian random vectors. Works well in the case the matrix \(A + \lambda \operatorname{I}\) is diagonal dominant. For more information, see the documentation of Conjugate Gradient Args: num_samples_estimator: number of samples to use in computation of Hutchinson's estimator
Source code in src/pydvl/influence/torch/preconditioner.py
fit
¶
Implement this to fit the pre-conditioner to the matrix represented by the mat_mat_prod Args: operator: The preconditioner is fitted to this operator regularization: regularization parameter \(\lambda\) in the equation $ ( A + \lambda \operatorname{I})x = \operatorname{rhs} $ Returns: self
Source code in src/pydvl/influence/torch/preconditioner.py
solve
¶
solve(rhs: Tensor)
Solve the equation \(M@Z = \operatorname{rhs}\) Args: rhs: right hand side of the equation, corresponds to the residuum vector (or matrix) in the conjugate gradient method
RETURNS | DESCRIPTION |
---|---|
solution \(M^{-1}\operatorname{rhs}\) |
Source code in src/pydvl/influence/torch/preconditioner.py
NystroemPreconditioner
¶
NystroemPreconditioner(rank: int)
Bases: Preconditioner
Pre-conditioner for improving the convergence of CG for systems of the form
The NystroemPreConditioner computes a low-rank approximation
where \((\cdot)^{\dagger}\) denotes the Moore-Penrose inverse, and uses the matrix
for pre-conditioning, where \( \sigma_{\text{rank}} \) is the smallest eigenvalue of the low-rank approximation.
Source code in src/pydvl/influence/torch/preconditioner.py
fit
¶
Implement this to fit the pre-conditioner to the matrix represented by the mat_mat_prod Args: operator: The preconditioner is fitted to this operator regularization: regularization parameter \(\lambda\) in the equation $ ( A + \lambda \operatorname{I})x = \operatorname{rhs} $ Returns: self
Source code in src/pydvl/influence/torch/preconditioner.py
solve
¶
solve(rhs: Tensor)
Solve the equation \(M@Z = \operatorname{rhs}\) Args: rhs: right hand side of the equation, corresponds to the residuum vector (or matrix) in the conjugate gradient method
RETURNS | DESCRIPTION |
---|---|
solution \(M^{-1}\operatorname{rhs}\) |