mrpro.operators.OptimizerOp
- class mrpro.operators.OptimizerOp[source]
Bases:
Operator
[Unpack
[ArgumentType
],VariableType
]Differentiable Optimization Operator.
Finds \(x^*=argmin_x f_p(x). The solution :math:`x^*\) will be differentiable with respect to some parameters \(p\) of the functional \(f\).
One of the building blocks of PINQI [ZIMM2024]
References
[ZIMM2024]Zimmermann, Felix F., et al. (2024) PINQI. An End-to-End Physics-Informed Approach to Learned Quantitative MRI Reconstruction. IEEE TCI. https://doi.org/10.1109/TCI.2024.3388869
- __init__(factory: Callable[[...], Callable[[...], tuple[Tensor]] | Operator[Any, tuple[Tensor]]], initializer: Callable[[Unpack[ArgumentType]], VariableType], optimize: Callable[[Callable, VariableType], VariableType] = default_lbfgs)[source]
Initialize a differentiable argmin solver.
- Parameters:
factory (
Callable
[...
,Union
[Callable
[...
,tuple
[Tensor
]],Operator
[Any
,tuple
[Tensor
]]]]) – Function, that given the parameters of the problem returns an objective function. The objective function should be a callable that takes the variable(s) as input and returns a scalar.initializer (
Callable
[[Unpack
[TypeVarTuple
]],TypeVar
(VariableType
, bound=tuple
[Tensor
,...
])]) – Function that, given the parameters of the problem, returns a tuple of initial values for the variable(s)optimize (
Callable
[[Callable
,TypeVar
(VariableType
, bound=tuple
[Tensor
,...
])],TypeVar
(VariableType
, bound=tuple
[Tensor
,...
])], default:default_lbfgs
) – Function used to perform the optimization, for examplelbfgs
. Usefunctools.partial
to setup up all settings besides the objective function and the initial values.
Example
Solving \(\|q(x)-y\|^2 + \alpha*\|x-x_\mathrm{reg}\|^2\) with \(y\), \(\alpha\) and \(x_\mathrm{reg}\) parameters. The solution \(x^*\) should be differentiable with respect to these.
Use:
def factory(y, alpha, x_reg): return L2squared(y)@q+alpha*L2squared(x_reg) def initializer(_y, _alpha, _xreg): return (x_reg,)
- Returns:
The argmin
x^*
- __call__(*args: Unpack[Tin]) Tout [source]
Apply the forward operator.
For more information, see
forward
.
- forward(*parameters: Unpack[ArgumentType]) VariableType [source]
Find the argmin.
- Parameters:
parameters (
Unpack
[TypeVarTuple
]) – Parameters of the argmin problem.
- __add__(other: Operator[Unpack[Tin], Tout]) Operator[Unpack[Tin], Tout] [source]
- __add__(other: Tensor | complex) Operator[Unpack[Tin], tuple[Unpack[Tin]]]
Operator addition.
Returns
lambda x: self(x) + other(x)
if other is a operator,lambda x: self(x) + other*x
if other is a tensor
- __matmul__(other: Operator[Unpack[Tin2], tuple[Unpack[Tin]]] | Operator[Unpack[Tin2], tuple[Tensor, ...]]) Operator[Unpack[Tin2], Tout] [source]
Operator composition.
Returns
lambda x: self(other(x))
- __mul__(other: Tensor | complex) Operator[Unpack[Tin], Tout] [source]
Operator multiplication with tensor.
Returns
lambda x: self(x*other)