tfmri.linalg.conjugate_gradient

conjugate_gradient(operator, rhs, preconditioner=None, x=None, tol=1e-05, max_iterations=20, bypass_gradient=False, name=None)[source]

Conjugate gradient solver.

Solves a linear system of equations \(Ax = b\) for self-adjoint, positive definite matrix \(A\) and right-hand side vector \(b\), using an iterative, matrix-free algorithm where the action of the matrix \(A\) is represented by operator. The iteration terminates when either the number of iterations exceeds max_iterations or when the residual norm has been reduced to tol times its initial value, i.e. \((\left\| b - A x_k \right\| <= \mathrm{tol} \left\| b \right\|\\)\).

Note

This function is similar to tf.linalg.experimental.conjugate_gradient, except it adds support for complex-valued linear systems and for imaging operators.

Parameters
  • operator – A LinearOperator that is self-adjoint and positive definite.

  • rhs – A tf.Tensor of shape [..., N]. The right hand-side of the linear system.

  • preconditioner – A LinearOperator that approximates the inverse of A. An efficient preconditioner could dramatically improve the rate of convergence. If preconditioner represents matrix M``(``M approximates A^{-1}), the algorithm uses preconditioner.apply(x) to estimate A^{-1}x. For this to be useful, the cost of applying M should be much lower than computing A^{-1} directly.

  • x

    A tf.Tensor of shape [..., N]. The initial guess for the solution.

  • tol – A float scalar convergence tolerance.

  • max_iterations – An int giving the maximum number of iterations.

  • bypass_gradient – A boolean. If True, the gradient with respect to rhs will be computed by applying the inverse of operator to the upstream gradient with respect to x (through CG iteration), instead of relying on TensorFlow’s automatic differentiation. This may reduce memory usage when training neural networks, but operator must not have any trainable parameters. If False, gradients are computed normally. For more details, see ref. [1].

  • name – A name scope for the operation.

Returns

A namedtuple representing the final state with fields

  • i: A scalar int32 tf.Tensor. Number of iterations executed.

  • x: A rank-1 tf.Tensor of shape [..., N] containing the computed

    solution.

  • r: A rank-1 tf.Tensor of shape [.., M] containing the residual vector.

  • p: A rank-1 tf.Tensor of shape [..., N]. A-conjugate basis vector.

  • gamma: \(r dot M dot r\), equivalent to \(||r||_2^2\) when preconditioner=None.

Raises

ValueError – If operator is not self-adjoint and positive definite.

References

1

Aggarwal, H. K., Mani, M. P., & Jacob, M. (2018). MoDL: Model-based deep learning architecture for inverse problems. IEEE transactions on medical imaging, 38(2), 394-405.