PnPULA#

class cuqi.experimental.mcmc.PnPULA(target=None, scale=1.0, smoothing_strength=0.1, **kwargs)#

Plug-and-Play Unadjusted Langevin algorithm (PnP-ULA) (Laumont et al., 2022)

Samples a smoothed target distribution given its smoothed logpdf gradient based on Langevin diffusion dL_t = dW_t + 1/2*Nabla target.logd(L_t)dt, where W_t is a dim-dimensional standard Brownian motion. It targets a differentiable density (partially) smoothed by a convolution with Gaussian kernel with zero mean and smoothing_strength variance. The smoothed target density can be made arbitrarily closed to the true unsmoothed target density.

For more details see: Laumont, R., Bortoli, V. D., Almansa, A., Delon, J., Durmus, A., & Pereyra, M. (2022). Bayesian imaging using plug & play priors: when Langevin meets Tweedie. SIAM Journal on Imaging Sciences, 15(2), 701-737.

Parameters:
  • target (cuqi.distribution.Distribution) – The target distribution to sample. The target distribution result from a differentiable likelihood and prior of type RestorationPrior.

  • initial_point (ndarray) – Initial parameters. Optional

  • scale (float) – The Langevin diffusion discretization time step (In practice, a scale of 1/L, where L is the Lipschitz of the gradient of the log target density is recommended but not guaranteed to be the optimal choice).

  • smoothing_strength (float) – This parameter controls the smoothing strength of PnP-ULA.

callbackcallable, 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).

# TODO: update demo once sampler merged

__init__(target=None, scale=1.0, smoothing_strength=0.1, **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, scale, smoothing_strength])

Initializer for abstract base class for all samplers.

get_history()

Return the history of the sampler.

get_samples()

Return the samples.

get_state()

Return the state of the sampler.

initialize()

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.

reinitialize()

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_target()

Validate the target is compatible with the sampler.

warmup(Nb[, tune_freq])

Warmup the sampler by drawing Nb samples.

Attributes

dim

Dimension of the target density.

geometry

Geometry of the target density.

target

Return the target density.