Apply the model to get p(x_{t-1} | x_t), as well as a prediction of the initial x_0.
(self, model, x_t, t, clip_denoised: bool = False, model_kwargs=None)
| 304 | return posterior_mean, posterior_variance, posterior_log_variance_clipped |
| 305 | |
| 306 | def p_mean_variance(self, model, x_t, t, clip_denoised: bool = False, model_kwargs=None): |
| 307 | """ |
| 308 | Apply the model to get p(x_{t-1} | x_t), as well as a prediction of |
| 309 | the initial x_0. |
| 310 | """ |
| 311 | model_kwargs = model_kwargs or {} |
| 312 | model_out = model(x_t, t, **model_kwargs) |
| 313 | if self.parameterization == "eps": |
| 314 | pred_xstart = self.predict_start_from_noise(x_t, t=t, noise=model_out) |
| 315 | elif self.parameterization == "v": |
| 316 | pred_xstart = self.predict_start_from_z_and_v(x_t, t=t, v=model_out) |
| 317 | elif self.parameterization == "x0": |
| 318 | pred_xstart = model_out |
| 319 | else: |
| 320 | raise NotImplementedError(f"Parameterization {self.parameterization} not yet supported") |
| 321 | |
| 322 | if clip_denoised: |
| 323 | pred_xstart.clamp_(-1., 1.) |
| 324 | |
| 325 | model_mean, posterior_variance, posterior_log_variance = self.q_posterior( |
| 326 | x_start=pred_xstart, x_t=x_t, t=t |
| 327 | ) |
| 328 | |
| 329 | return { |
| 330 | 'mean': model_mean, |
| 331 | 'variance': posterior_variance, |
| 332 | 'log_variance': posterior_log_variance, |
| 333 | 'pred_xstart': pred_xstart, |
| 334 | } |
| 335 | |
| 336 | def p_sample(self, model, x_t, t, clip_denoised=True, model_kwargs=None): |
| 337 | """ |
no test coverage detected