DiffusionSampler#
- class deepinv.sampling.DiffusionSampler(diffusion, max_iter=100.0, clip=(-1, 2), thres_conv=0.1, g_statistic=<function DiffusionSampler.<lambda>>, verbose=True, save_chain=False)[source]#
Bases:
MonteCarlo
Turns a diffusion method into a Monte Carlo sampler
Unlike diffusion methods, the resulting sampler computes the mean and variance of the distribution by running the diffusion multiple times.
- Parameters:
diffusion (torch.nn.Module) – a diffusion model
max_iter (int) – the maximum number of iterations
clip (tuple) – the clip range
g_statistic (callable) – the algorithm computes mean and variance of the g function, by default \(g(x) = x\).
thres_conv (float) – the convergence threshold for the mean and variance
verbose (bool) – whether to print the progress
save_chain (bool) – whether to save the chain
thinning (int) – the thinning factor
burnin_ratio (float) – the burnin ratio
Examples using DiffusionSampler
:#
Image reconstruction with a diffusion model
Image reconstruction with a diffusion model