MCPcopy Index your code
hub / github.com/VisionXLab/OF-Diff / p_sample

Method p_sample

ldm/models/diffusion/ddpm.py:333–339  ·  view source on GitHub ↗
(self, x, t, clip_denoised=True, repeat_noise=False)

Source from the content-addressed store, hash-verified

331
332 @torch.no_grad()
333 def p_sample(self, x, t, clip_denoised=True, repeat_noise=False):
334 b, *_, device = *x.shape, x.device
335 model_mean, _, model_log_variance = self.p_mean_variance(x=x, t=t, clip_denoised=clip_denoised)
336 noise = noise_like(x.shape, device, repeat_noise)
337 # no noise when t == 0
338 nonzero_mask = (1 - (t == 0).float()).reshape(b, *((1,) * (len(x.shape) - 1)))
339 return model_mean + nonzero_mask * (0.5 * model_log_variance).exp() * noise
340
341 @torch.no_grad()
342 def p_sample_loop(self, shape, return_intermediates=False):

Callers 1

p_sample_loopMethod · 0.95

Calls 2

p_mean_varianceMethod · 0.95
noise_likeFunction · 0.90

Tested by

no test coverage detected