MCPcopy Create free account
hub / github.com/openai/point-e / _prior_bpd

Method _prior_bpd

point_e/diffusion/gaussian_diffusion.py:849–863  ·  view source on GitHub ↗

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

(self, x_start)

Source from the content-addressed store, hash-verified

847 return terms
848
849 def _prior_bpd(self, x_start):
850 """
851 Get the prior KL term for the variational lower-bound, measured in
852 bits-per-dim.
853
854 This term can't be optimized, as it only depends on the encoder.
855
856 :param x_start: the [N x C x ...] tensor of inputs.
857 :return: a batch of [N] KL values (in bits), one per batch element.
858 """
859 batch_size = x_start.shape[0]
860 t = th.tensor([self.num_timesteps - 1] * batch_size, device=x_start.device)
861 qt_mean, _, qt_log_variance = self.q_mean_variance(x_start, t)
862 kl_prior = normal_kl(mean1=qt_mean, logvar1=qt_log_variance, mean2=0.0, logvar2=0.0)
863 return mean_flat(kl_prior) / np.log(2.0)
864
865 def calc_bpd_loop(self, model, x_start, clip_denoised=False, model_kwargs=None):
866 """

Callers 1

calc_bpd_loopMethod · 0.95

Calls 3

q_mean_varianceMethod · 0.95
normal_klFunction · 0.85
mean_flatFunction · 0.85

Tested by

no test coverage detected