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