sampling_builder#

deepinv.sampling.sampling_builder(iterator, data_fidelity, prior, params_algo={}, max_iter=100, thresh_conv=1e-3, burnin_ratio=0.2, thinning=10, history_size=5, verbose=False, callback=lambda X, **kwargs: ..., **kwargs)[source]#

Helper function for building an instance of the deepinv.sampling.BaseSampling class.

See Uncertainty quantification with PnP-ULA. and Markov Chain Monte Carlo for example usage.

See the docs for deepinv.sampling.BaseSampling for further examples and information.

Parameters:
  • iterator (SamplingIterator | str) – Either a SamplingIterator instance or a string naming the iterator class

  • data_fidelity (DataFidelity) – Negative log-likelihood function

  • prior (Prior) – Negative log-prior

  • params_algo (dict) – Dictionary containing the parameters for the algorithm

  • max_iter (int) – Number of Monte Carlo iterations

  • burnin_ratio (float) – Percentage of iterations for burn-in

  • thinning (int) – Integer to thin the Monte Carlo samples

  • history_size (int | bool) – Number of most recent samples to store in memory. If True, all samples are stored. If False, no samples are stored. If an integer, it specifies the number of most recent samples to store. Default: 5

  • verbose (bool) – Whether to print progress

  • callback (Callable) – A function that is called on every (thinned) sample state dictionary for diagnostics. It is called with the current sample X, the current statistics (a list of Welford objects), and the current iteration number iter as keyword arguments.

  • kwargs – Additional keyword arguments passed to the iterator constructor when a string is provided as the iterator parameter

Returns:

Configured BaseSampling instance in eval mode

Return type:

BaseSampling

Examples using sampling_builder:#

Building your custom MCMC sampling algorithm.

Building your custom MCMC sampling algorithm.

Uncertainty quantification with PnP-ULA.

Uncertainty quantification with PnP-ULA.