MCPcopy Create free account
hub / github.com/Zhiyuan-R/Tiger-Diffusion / q_sample

Method q_sample

train_generation.py:159–169  ·  view source on GitHub ↗

Diffuse the data (t == 0 means diffused for 1 step)

(self, x_start, t, noise=None)

Source from the content-addressed store, hash-verified

157 return mean, variance, log_variance
158
159 def q_sample(self, x_start, t, noise=None):
160 """
161 Diffuse the data (t == 0 means diffused for 1 step)
162 """
163 if noise is None:
164 noise = torch.randn(x_start.shape, device=x_start.device)
165 assert noise.shape == x_start.shape
166 return (
167 self._extract(self.sqrt_alphas_cumprod.to(x_start.device), t, x_start.shape) * x_start +
168 self._extract(self.sqrt_one_minus_alphas_cumprod.to(x_start.device), t, x_start.shape) * noise
169 )
170
171
172 def q_posterior_mean_variance(self, x_start, x_t, t):

Callers 2

p_lossesMethod · 0.95
calc_bpd_loopMethod · 0.95

Calls 1

_extractMethod · 0.95

Tested by

no test coverage detected