RegularizedLinearRTO#
- class cuqi.experimental.mcmc.RegularizedLinearRTO(target=None, initial_point=None, maxit=100, inner_max_it=10, stepsize='automatic', penalty_parameter=10, abstol=1e-10, adaptive=True, solver=None, inner_abstol=None, **kwargs)#
Regularized Linear RTO (Randomize-Then-Optimize) sampler.
Samples posterior related to the inverse problem with Gaussian likelihood and implicit Gaussian prior, and where the forward model is Linear. The sampler works by repeatedly solving regularized linear least squares problems for perturbed data. The solver for these optimization problems is chosen based on how the regularized is provided in the implicit Gaussian prior. Currently we use the following solvers: FISTA: [1] Beck, Amir, and Marc Teboulle. “A fast iterative shrinkage-thresholding algorithm for linear inverse problems.” SIAM journal on imaging sciences 2.1 (2009): 183-202.
Used when prior.proximal is callable.
- ADMM: [2] Boyd et al. “Distributed optimization and statistical learning via the alternating direction method of multipliers.”Foundations and Trends® in Machine learning, 2011.
Used when prior.proximal is a list of penalty terms.
ScipyLinearLSQ: Wrapper for Scipy’s lsq_linear for the Trust Region Reflective algorithm. Optionally used when the constraint is either “nonnegativity” or “box”.
- Parameters:
target (cuqi.distribution.Posterior) – See cuqi.sampler.LinearRTO
initial_point (np.ndarray) – Initial point for the sampler. Optional.
maxit (int) – Maximum number of iterations of the FISTA/ADMM/ScipyLinearLSQ solver. Optional.
inner_max_it (int) – Maximum number of iterations of the CGLS solver used within the ADMM solver. Optional.
stepsize (string or float) – If stepsize is a string and equals either “automatic”, then the stepsize is automatically estimated based on the spectral norm. If stepsize is a float, then this stepsize is used.
penalty_parameter (int) – Penalty parameter of the ADMM solver. Optional. See [2] or cuqi.solver.ADMM
abstol (float) – Absolute tolerance of the FISTA/ScipyLinearLSQ solver. Optional.
inner_abstol (float) – Tolerance parameter for ScipyLinearLSQ’s inner solve of the unbounded least-squares problem. Optional.
adaptive (bool) – If True, FISTA is used as solver, otherwise ISTA is used. Optional.
solver (string) – If set to “ScipyLinearLSQ”, solver is set to cuqi.solver.ScipyLinearLSQ, otherwise FISTA/ISTA or ADMM is used. Note “ScipyLinearLSQ” can only be used with RegularizedGaussian of box or nonnegativity constraint. Optional.
callback (callable, optional) – A function that will be called after each sampling step. It can be useful for monitoring the sampler during sampling. The function should take three arguments: the sampler object, the index of the current sampling step, the total number of requested samples. The last two arguments are integers. An example of the callback function signature is: callback(sampler, sample_index, num_of_samples).
- __init__(target=None, initial_point=None, maxit=100, inner_max_it=10, stepsize='automatic', penalty_parameter=10, abstol=1e-10, adaptive=True, solver=None, inner_abstol=None, **kwargs)#
Initializer for abstract base class for all samplers.
Any subclassing samplers should simply store input parameters as part of the __init__ method.
The actual initialization of the sampler should be done in the _initialize method.
- Parameters:
target (cuqi.density.Density) – The target density.
initial_point (array-like, optional) – The initial point for the sampler. If not given, the sampler will choose an initial point.
callback (callable, optional) – A function that will be called after each sampling step. It can be useful for monitoring the sampler during sampling. The function should take three arguments: the sampler object, the index of the current sampling step, the total number of requested samples. The last two arguments are integers. An example of the callback function signature is: callback(sampler, sample_index, num_of_samples).
Methods
__init__
([target, initial_point, maxit, ...])Initializer for abstract base class for all samplers.
Return the history of the sampler.
Return the samples.
Return the state of the sampler.
Initialize the sampler by setting and allocating the state and history before sampling starts.
load_checkpoint
(path)Load the state of the sampler from a file.
Re-initialize the sampler.
sample
(Ns[, batch_size, sample_path])Sample Ns samples from the target density.
save_checkpoint
(path)Save the state of the sampler to a file.
set_history
(history)Set the history of the sampler.
set_state
(state)Set the state of the sampler.
step
()Perform one step of the sampler by transitioning the current point to a new point according to the sampler's transition kernel.
tune
(skip_len, update_count)Tune the parameters of the sampler.
Validate the target is compatible with the sampler.
warmup
(Nb[, tune_freq])Warmup the sampler by drawing Nb samples.
Attributes
Dimension of the target density.
Geometry of the target density.
Return the target density.