(self, x, t, clip_denoised=True, repeat_noise=False)
| 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): |
no test coverage detected