mirtorch.alg.CG

class mirtorch.alg.CG(A, max_iter=20, tol=0.01, P=None, alert=False, eval_func=None)

Solve the equation \(Ax = b\) with the conjugate gradient method, where A is a PSD matrix. The backpropagation still calls the CG to calculate the Jacobian to save the memory.

A

LinearMap of a PSD matrix

tol

float, exiting tolerance

max_iter

int, max number of iterations

alert

bool, print the norm of residuals at the end

eval_func

user-defined function to calculate the loss at each iteration.

P

LinearMap of a Preconditioner

run()

run the CG algorithm

__init__(A, max_iter=20, tol=0.01, P=None, alert=False, eval_func=None)

Methods

__init__(A[, max_iter, tol, P, alert, eval_func])

run(x0, b)

Run the CG iterations.