LION.reconstructors.LearnedRegularizerReconstructor

class LION.reconstructors.LearnedRegularizerReconstructor(operator, model=None, parameters=None)[source]

Bases: LIONReconstructor

Reconstruct by minimising a variational energy with a learned regulariser,

\[E(x) = \tfrac12 \lVert A x - y \rVert_2^2 + \alpha R(x),\]

by gradient descent with a backtracking (Armijo) step size, starting from the parameters’ initial_reconstruction (by default the operator’s default reconstruction, FDK for CT). Each measurement is reconstructed on its own (a batch is reconstructed sample by sample).

Works with any regulariser R (model), however it was trained: adversarial (AR), convex (ACR), … A LIONmodel regulariser is called on a batch of one image, normalised as set by its set_normalisation(), and may return a (1, 1) value; any other callable is called on the image as it is (the operator’s domain shape). Its output is summed to a scalar.

LearnedRegularizerReconstructor(operator, model, parameters), with parameters from default_parameters():

  • alpha: regularisation weight (see estimate_alpha);

  • n_steps: number of gradient descent iterations;

  • step_size: initial gradient step;

  • backtracking: factor (< 1) by which the step is reduced until the Armijo condition holds. After an accepted step it grows again by 1 / backtracking.

__init__(operator, model=None, parameters=None)[source]

Methods

__init__(operator[, model, parameters])

cite([cite_format])

The variational reconstruction with a learned regulariser of the adversarial regulariser paper; the regulariser has its own.

default_parameters()

alpha 1, 150 steps of initial size 1e-6, backtracking 0.95, and the operator's default reconstruction as the start (initial_reconstruction "default"; FDK for CT).

energy(x, y)

E(x) = 0.5 ||A x - y||^2 + alpha R(x), for one sample.

gradient(x, y)

grad E(x) = A^T (A x - y) + alpha grad R(x), for one sample.

initial_guess(y)

Where the algorithm starts for measurements y: the parameters' initial_reconstruction(y, op).

instantiate(source[, model, allow])

The reconstructor source describes: its file (save), its spec, or a test record (LION.evaluation) of it, or that record's file.

load(fname, *[, allow])

The reconstructor fname (a file save wrote) describes, with its model loaded from the recorded file (a warning if its weights changed since).

parameters_from_file(source, *[, allow])

What default_parameters() gives, as source (as in instantiate) recorded it: the algorithm's settings, to change and make the reconstructor with (PnP(operator, model, parameters)).

reconstruct(y[, x0, verbose])

Reconstruct measurements y: one sample (the operator's range shape) or a batch of them, each on its own.

reconstruct_sample(y[, x0, verbose])

Reconstruct one measurement y (for CT, a sinogram (C, angles, detectors)).

regularizer_value(x)

R(x) as a scalar, for one image x in the operator's domain shape.

save(fname)

Write this reconstructor's record to fname (.json): its spec (operator and parameters), its model by the file it was loaded from and its weights hash (a model made in the script: only the hash; a function: its spec), and the environment.

spec_kwargs()

The spec's arguments: the operator and the parameters, not the model (a model's spec would make it with new weights; see the module docstring).

static default_parameters()[source]

alpha 1, 150 steps of initial size 1e-6, backtracking 0.95, and the operator’s default reconstruction as the start (initial_reconstruction “default”; FDK for CT).

regularizer_value(x)[source]

R(x) as a scalar, for one image x in the operator’s domain shape.

energy(x, y)[source]

E(x) = 0.5 ||A x - y||^2 + alpha R(x), for one sample.

gradient(x, y)[source]

grad E(x) = A^T (A x - y) + alpha grad R(x), for one sample.

The data term’s gradient is computed with the operator’s own forward and adjoint; only the regulariser (a network) is differentiated by autograd.

reconstruct_sample(y, x0=None, verbose=1)[source]

Reconstruct one measurement y (for CT, a sinogram (C, angles, detectors)).

Parameters:
  • x0 – Initial image; initial_guess(y) if None.

  • verbose – Show a progress bar over the iterations (>= 1).

Returns:

The reconstruction, in the operator’s domain shape.

static cite(cite_format='bib')[source]

The variational reconstruction with a learned regulariser of the adversarial regulariser paper; the regulariser has its own.