Get the prior KL term for the variational lower-bound, measured in bits-per-dim. This term can't be optimized, as it only depends on the encoder. :param x_start: the [N x C x ...] tensor of inputs. :return: a batch of [N] KL values (in bits), one per batch el
(self, x_start)
| 877 | extract_into_tensor(self.sqrt_recipm1_alphas_cumprod, t, x_t.shape) |
| 878 | |
| 879 | def _prior_bpd(self, x_start): |
| 880 | """ |
| 881 | Get the prior KL term for the variational lower-bound, measured in |
| 882 | bits-per-dim. |
| 883 | This term can't be optimized, as it only depends on the encoder. |
| 884 | :param x_start: the [N x C x ...] tensor of inputs. |
| 885 | :return: a batch of [N] KL values (in bits), one per batch element. |
| 886 | """ |
| 887 | batch_size = x_start.shape[0] |
| 888 | t = torch.tensor([self.num_timesteps - 1] * batch_size, device=x_start.device) |
| 889 | qt_mean, _, qt_log_variance = self.q_mean_variance(x_start, t) |
| 890 | kl_prior = normal_kl(mean1=qt_mean, logvar1=qt_log_variance, mean2=0.0, logvar2=0.0) |
| 891 | return mean_flat(kl_prior) / np.log(2.0) |
| 892 | |
| 893 | def p_losses(self, x_start, cond, t, noise=None): |
| 894 | noise = default(noise, lambda: torch.randn_like(x_start)) |
nothing calls this directly
no test coverage detected