optim.CG

Contents

optim.CG#

class bartorch.optim.CG#

Bases:

Conjugate gradients on the normal equations of a quadratic problem.

Solves

\[\min_x \; \| A x - y \|^2 + \lambda \| x \|^2 + \sum_i w_i \| G_i x - b_i \|^2\]

where the sum is over the Tikhonov terms.

Parameters:
  • lambda (float, default=0.0) – \(\lambda\), the Tikhonov weight on the image.

  • terms (Tikhonov or iterable of Tikhonov, default=None) – Quadratic penalties \(w_i \| G_i x - b_i \|^2\).

  • maxiter (int, default=30) – Maximum number of iterations.

  • tol (float, default=0.0) – Stop once the residual of the normal equations is at most tol * ||A^H y||; zero, BART’s default, runs every iteration.

  • cclambda (float, default=0.0) – Weight of an identity added to the normal operator (lsqr’s cclambda).

  • precond (LinearOperator, default=None) – Left preconditioner \(M\) from A.ishape to itself, positive definite (lsqr2_create’s precond_op); BART’s reconstructions use none.

Raises:

TypeError – A term is not a Tikhonov penalty, such as a proximal regularizer.

Notes

BART’s iter2_conjgrad takes the weight \(\lambda\) and no regularizing operators or biases. The terms are therefore stacked under the encoding, \([A; \sqrt{w_i} G_i] x \approx [y; \sqrt{w_i} b_i]\), and the stacked operator is solved; its normal is applied as the sum of the parts’ normals.

Examples

>>> CG(maxiter=30)(kspace, A)
>>> CG(terms=Tikhonov(0.1, bias=prior))(kspace, A)
>>> CG(terms=[Tikhonov(0.1, operator=G), Tikhonov(0.01)])(kspace, A)
__call__()#

Solve for the image.

Parameters:
  • y (tensor) – Data of A.oshape, or (batch, *A.oshape); a batch is solved one item at a time.

  • A (LinearOperator) – Encoding operator.

  • x0 (tensor, default=None) – Starting image of A.ishape, or one per batch item; zero when omitted.

  • steps (list, default=None) – When given, the number of iterations each solve took is appended to it.

Returns:

Complex64 image of A.ishape, with y’s batch axis in front.

Return type:

torch.Tensor

Notes

When y requires a gradient the solve is recorded as one operation: the forward pass is the library’s iteration, and the backward pass a second solve with the same normal operator (Learned reconstruction). The warm start receives no gradient. For a linearization of a nonlinear operator the gradient also reaches the point it was linearized at. The solve can therefore serve as the data-consistency layer of an unrolled network.