Compute the mean and variance of the diffusion posterior q(x_{t-1} | x_t, x_0)
(self, x_start, x_t, t)
| 291 | ) / extract_into_tensor(self.sqrt_recipm1_alphas_cumprod, t, x_t.shape) |
| 292 | |
| 293 | def q_posterior(self, x_start, x_t, t): |
| 294 | """ |
| 295 | Compute the mean and variance of the diffusion posterior q(x_{t-1} | x_t, x_0) |
| 296 | """ |
| 297 | assert x_start.shape == x_t.shape, f"Shape mismatch: {x_start.shape} != {x_t.shape}" |
| 298 | posterior_mean = ( |
| 299 | extract_into_tensor(self.posterior_mean_coef1, t, x_t.shape) * x_start + |
| 300 | extract_into_tensor(self.posterior_mean_coef2, t, x_t.shape) * x_t |
| 301 | ) |
| 302 | posterior_variance = extract_into_tensor(self.posterior_variance, t, x_t.shape) |
| 303 | posterior_log_variance_clipped = extract_into_tensor(self.posterior_log_variance_clipped, t, x_t.shape) |
| 304 | return posterior_mean, posterior_variance, posterior_log_variance_clipped |
| 305 | |
| 306 | def p_mean_variance(self, model, x_t, t, clip_denoised: bool = False, model_kwargs=None): |
| 307 | """ |
no test coverage detected