Inversion
Contains methods to invert the hessian vector product.
InversionRegistry
¶
A registry to hold inversion methods for different models.
register(model_type, inversion_method, overwrite=False)
classmethod
¶
Register a function for a specific model type and inversion method.
The function to be registered must conform to the following signature:
(model: TwiceDifferentiable, training_data: DataLoaderType, b: TensorType,
hessian_perturbation: float = 0.0, ...)
.
PARAMETER | DESCRIPTION |
---|---|
model_type |
The type of the model the function should be registered for.
TYPE:
|
inversion_method |
The inversion method the function should be registered for.
TYPE:
|
overwrite |
If
TYPE:
|
RAISES | DESCRIPTION |
---|---|
TypeError
|
If the provided model_type or inversion_method are of the wrong type. |
ValueError
|
If the function to be registered does not match the required signature. |
RETURNS | DESCRIPTION |
---|---|
A decorator for registering a function. |
Source code in src/pydvl/influence/inversion.py
call(inversion_method, model, training_data, b, hessian_perturbation, **kwargs)
classmethod
¶
Call a registered function with the provided parameters.
PARAMETER | DESCRIPTION |
---|---|
inversion_method |
The inversion method to use.
TYPE:
|
model |
A model wrapped in the TwiceDifferentiable interface.
TYPE:
|
training_data |
The training data to use.
TYPE:
|
b |
Array as the right hand side of the equation \(Ax = b\).
TYPE:
|
hessian_perturbation |
Regularization of the hessian.
|
kwargs |
Additional keyword arguments to pass to the inversion method.
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
InverseHvpResult
|
An instance of InverseHvpResult, that contains an array, which solves the inverse problem, i.e. it returns \(x\) such that \(Ax = b\), and a dictionary containing information about the inversion process. |
Source code in src/pydvl/influence/inversion.py
solve_hvp(inversion_method, model, training_data, b, *, hessian_perturbation=0.0, **kwargs)
¶
Finds \( x \) such that \( Ax = b \), where \( A \) is the hessian of the model, and \( b \) a vector. Depending on the inversion method, the hessian is either calculated directly and then inverted, or implicitly and then inverted through matrix vector product. The method also allows to add a small regularization term (hessian_perturbation) to facilitate inversion of non fully trained models.
PARAMETER | DESCRIPTION |
---|---|
inversion_method |
TYPE:
|
model |
A model wrapped in the TwiceDifferentiable interface.
TYPE:
|
training_data |
TYPE:
|
b |
Array as the right hand side of the equation \( Ax = b \)
TYPE:
|
hessian_perturbation |
regularization of the hessian.
TYPE:
|
kwargs |
kwargs to pass to the inversion method.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
InverseHvpResult
|
Instance of InverseHvpResult, with an array that solves the inverse problem, i.e., it returns \( x \) such that \( Ax = b \) and a dictionary containing information about the inversion process. |
Source code in src/pydvl/influence/inversion.py
Created: 2023-10-14