MCPcopy Create free account
hub / github.com/VisionXLab/OF-Diff / q_mean_variance

Method q_mean_variance

ldm/models/diffusion/ddpm.py:279–289  ·  view source on GitHub ↗

Get the distribution q(x_t | x_0). :param x_start: the [N x C x ...] tensor of noiseless inputs. :param t: the number of diffusion steps (minus 1). Here, 0 means one step. :return: A tuple (mean, variance, log_variance), all of x_start's shape.

(self, x_start, t)

Source from the content-addressed store, hash-verified

277 print(f"\nUnexpected Keys:\n {unexpected}")
278
279 def q_mean_variance(self, x_start, t):
280 """
281 Get the distribution q(x_t | x_0).
282 :param x_start: the [N x C x ...] tensor of noiseless inputs.
283 :param t: the number of diffusion steps (minus 1). Here, 0 means one step.
284 :return: A tuple (mean, variance, log_variance), all of x_start's shape.
285 """
286 mean = (extract_into_tensor(self.sqrt_alphas_cumprod, t, x_start.shape) * x_start)
287 variance = extract_into_tensor(1.0 - self.alphas_cumprod, t, x_start.shape)
288 log_variance = extract_into_tensor(self.log_one_minus_alphas_cumprod, t, x_start.shape)
289 return mean, variance, log_variance
290
291 def predict_start_from_noise(self, x_t, t, noise):
292 return (

Callers 1

_prior_bpdMethod · 0.80

Calls 1

extract_into_tensorFunction · 0.90

Tested by

no test coverage detected