MCPcopy Create free account
hub / github.com/DPS2022/diffusion-posterior-sampling / p_sample

Method p_sample

guided_diffusion/gaussian_diffusion.py:365–373  ·  view source on GitHub ↗
(self, model, x, t)

Source from the content-addressed store, hash-verified

363@register_sampler(name='ddpm')
364class DDPM(SpacedDiffusion):
365 def p_sample(self, model, x, t):
366 out = self.p_mean_variance(model, x, t)
367 sample = out['mean']
368
369 noise = torch.randn_like(x)
370 if t != 0: # no noise when t == 0
371 sample += torch.exp(0.5 * out['log_variance']) * noise
372
373 return {'sample': sample, 'pred_xstart': out['pred_xstart']}
374
375
376@register_sampler(name='ddim')

Callers

nothing calls this directly

Calls 1

p_mean_varianceMethod · 0.45

Tested by

no test coverage detected