MCPcopy Create free account
hub / github.com/Sin3DM/Sin3DM / q_sample

Method q_sample

src/diffusion/gaussian_diffusion.py:189–207  ·  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

187 return mean, variance, log_variance
188
189 def q_sample(self, x_start, t, noise=None):
190 """
191 Diffuse the data for a given number of diffusion steps.
192
193 In other words, sample from q(x_t | x_0).
194
195 :param x_start: the initial data batch.
196 :param t: the number of diffusion steps (minus 1). Here, 0 means one step.
197 :param noise: if specified, the split-out normal noise.
198 :return: A noisy version of x_start.
199 """
200 if noise is None:
201 noise = th.randn_like(x_start)
202 assert noise.shape == x_start.shape
203 return (
204 _extract_into_tensor(self.sqrt_alphas_cumprod, t, x_start.shape) * x_start
205 + _extract_into_tensor(self.sqrt_one_minus_alphas_cumprod, t, x_start.shape)
206 * noise
207 )
208
209 def q_posterior_mean_variance(self, x_start, x_t, t):
210 """

Callers 2

training_lossesMethod · 0.95
calc_bpd_loopMethod · 0.95

Calls 1

_extract_into_tensorFunction · 0.85

Tested by

no test coverage detected