nlop.IRGNMBlock#
- class bartorch.nlop.IRGNMBlock#
Bases:
ModuleOne step of iteratively regularized Gauss-Newton,
noir’s Gauss-Newton step.Without
innerthe step is BART’s first form,x = xn + (DF^H DF + alpha)^-1 [DF^H (y - F(xn)) - alpha (xn - xref)],with the inverse computed by conjugate gradients inside the library and differentiated implicitly. With
innerit is the second form: the solver minimizes||DF u - r||^2 + alpha ||u||^2 + R(u)forDFlinearized atxnandr = y - F(xn) + DF (xn - xref), andx = u + xref. The weight then decays asalpha <- (alpha - alpha_min) / redu + alpha_min, and in the second form is kept abovealpha_min0.state = block.start(y, F, x0, xref)prepares the data and the model,state = block(state, F)takes one step, andblock.output(state, F)returns the unknowns.alphais the weight of the first step: the block taking stepkapplies it decayedktimes, so one block looped, or a stack of blocks with the samealpha, is BART’s schedule, and a stack whose blocks learnalphalearns a weight per step.Fneeds a_bundled. A leading batch axis onyis a batch of independent items, each stepped on its own; a model that holds its items, asCoilSense(..., items=True)does, is stepped as one, with each item’s inner problem solved on its own.- Parameters:
alpha (float, default=1.0) – Initial Tikhonov weight.
alpha_min (float, default=0.0) – What the weight decays towards.
alpha_min0 (float, default=0.0) – Floor the decayed weight is never taken below; second form only.
redu (float, default=2.0) – Factor the weight is divided by after each step.
cg_maxiter (int, default=30) – The first form’s conjugate-gradient iterations,
iter_conjgrad_conf’smaxiter.cg_tol (float, default=0.0) – Its tolerance,
iter_conjgrad_conf’stol. A nonzerotolis refused by BART once the step is differentiated.cg_lambda (float, default=0.0) – Its Tikhonov weight,
iter_conjgrad_conf’sl2lambda.inner (solver, default=None) – A configured solver from
bartorch.optimfor the linearized problem; its regularizers areR.fuse (bool, default=True) – Lower a coil composition so that its encoding is applied once as its normal operator; see
plan().
Notes
alphaandreduaretorch.nn.Parameterobjects, frozen untilrequires_grad_(). The first form is differentiable by the data, the iterate, the centre andalpha. The second form is differentiable by the data, the iterate, the centre and the inner solver’s own settings and priors; it givesalphato the solver as a number, soalphais held fixed there.- plan()#
What
Fwas lowered into, as aPlan.plan.derivativesays where the derivative came from,plan.domainwhether the step works against the normal operator or applies the encoding forward and adjoint,plan.encodingthe linear part’s own plan, andplan.fusedwhether the coil model was rewritten.
- start()#
The run’s state: the prepared data, the start, the centre and the weight.
x0andxrefare a state (the unknowns laid end to end), the one unknown of a single-input model at its shape, or a tuple of unknowns. Withoutx0the start isnlinv’s: the first unknown ones, the rest zero. Withoutxrefthe steps are regularized towards zero.
- forward()#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- output()#
The unknowns: a tensor for a model of one input, else one per input.