MCPcopy Create free account
hub / github.com/MotrixLab/FineMoGen / q_sample

Method q_sample

mogen/models/utils/gaussian_diffusion.py:403–420  ·  view source on GitHub ↗

Diffuse the data for a given number of diffusion steps. In other words, sample from q(x_t | x_0). :param x_start: the initial data batch. :param t: the number of diffusion steps (minus 1). Here, 0 means one step. :param noise: if specified, the split-out no

(self, x_start, t, noise=None)

Source from the content-addressed store, hash-verified

401 return mean, variance, log_variance
402
403 def q_sample(self, x_start, t, noise=None):
404 """
405 Diffuse the data for a given number of diffusion steps.
406
407 In other words, sample from q(x_t | x_0).
408
409 :param x_start: the initial data batch.
410 :param t: the number of diffusion steps (minus 1). Here, 0 means one step.
411 :param noise: if specified, the split-out normal noise.
412 :return: A noisy version of x_start.
413 """
414 if noise is None:
415 noise = th.randn_like(x_start)
416 assert noise.shape == x_start.shape
417 return (
418 _extract_into_tensor(self.sqrt_alphas_cumprod, t, x_start.shape) *
419 x_start + _extract_into_tensor(self.sqrt_one_minus_alphas_cumprod,
420 t, x_start.shape) * noise)
421
422 def q_posterior_mean_variance(self, x_start, x_t, t):
423 """

Callers 4

p_sampleMethod · 0.95
ddim_sampleMethod · 0.95
training_lossesMethod · 0.95
calc_bpd_loopMethod · 0.95

Calls 1

_extract_into_tensorFunction · 0.85

Tested by

no test coverage detected