Diffuse the data for a given number of diffusion steps => sample x_t ~ q(x_t | x_0) with x_t = sqrt(alpha_bar_t) * x_0 + sqrt(1 - alpha_bar_t) * noise
(self, x_start, t, noise=None)
| 197 | return mean, variance, log_variance |
| 198 | |
| 199 | def q_sample(self, x_start, t, noise=None): |
| 200 | """ |
| 201 | Diffuse the data for a given number of diffusion steps |
| 202 | => sample x_t ~ q(x_t | x_0) with |
| 203 | x_t = sqrt(alpha_bar_t) * x_0 + sqrt(1 - alpha_bar_t) * noise |
| 204 | """ |
| 205 | if noise is None: |
| 206 | noise = torch.randn_like(x_start) |
| 207 | sqrt_alpha_cumprod_t = extract_into_tensor(self.sqrt_alphas_cumprod, t, x_start.shape) |
| 208 | sqrt_one_minus_alpha_cumprod_t = extract_into_tensor(self.sqrt_one_minus_alphas_cumprod, t, x_start.shape) |
| 209 | return sqrt_alpha_cumprod_t * x_start + sqrt_one_minus_alpha_cumprod_t * noise |
| 210 | |
| 211 | def get_v(self, x_start, noise, t): |
| 212 | """ v-parameterization: sqrt(alpha_bar_t) * eps - sqrt(1 - alpha_bar_t) * x_0 """ |
no test coverage detected