Diffuse the data (t == 0 means diffused for 1 step)
(self, x_start, t, noise=None)
| 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): |
no test coverage detected