MCPcopy Index your code
hub / github.com/CompVis/diff2flow / q_posterior

Method q_posterior

diff2flow/ddpm.py:293–304  ·  view source on GitHub ↗

Compute the mean and variance of the diffusion posterior q(x_{t-1} | x_t, x_0)

(self, x_start, x_t, t)

Source from the content-addressed store, hash-verified

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 """

Callers 2

p_mean_varianceMethod · 0.95
_vb_terms_bpdMethod · 0.95

Calls 1

extract_into_tensorFunction · 0.70

Tested by

no test coverage detected