def build_prior_KL(self): # whitening of priors can be implemented here """ This gives KL divergence between inducing points priors and approximated posteriors KL(q(u_g)||p(u_g)) + KL(q(u_f)||p(u_f)) q(u_f) = N(u_f|u_fm,u_fs) p(u_f) = N(u_f|0,Kfmm) q(u_g) = N(u_g|u_gm,u_gs) p(u_g) = N(u_g|0,Kgmm) """ if self.whiten: if self.q_diag: KL = kullback_leiblers.gauss_kl_white_diag(self.u_fm, self.u_fs_sqrt) + \ kullback_leiblers.gauss_kl_white_diag(self.u_gm, self.u_gs_sqrt) else: KL = kullback_leiblers.gauss_kl_white(self.u_fm, self.u_fs_sqrt) + \ kullback_leiblers.gauss_kl_white(self.u_gm, self.u_gs_sqrt) else: Kfmm = self.kernf.K(self.Zf) + tf.eye( self.num_inducing_f, dtype=float_type) * settings.numerics.jitter_level Kgmm = self.kerng.K(self.Zg) + tf.eye( self.num_inducing_g, dtype=float_type) * settings.numerics.jitter_level if self.q_diag: KL = kullback_leiblers.gauss_kl_diag(self.u_fm, self.u_fs_sqrt, Kfmm) + \ kullback_leiblers.gauss_kl_diag(self.u_gm, self.u_gs_sqrt, Kgmm) else: KL = kullback_leiblers.gauss_kl(self.u_fm, self.u_fs_sqrt, Kfmm) + \ kullback_leiblers.gauss_kl(self.u_gm, self.u_gs_sqrt, Kgmm) return KL
def build_prior_KL(self): if self.whiten: if self.q_diag: KL = kullback_leiblers.gauss_kl_white_diag( self.q_mu, self.q_sqrt) else: KL = kullback_leiblers.gauss_kl_white(self.q_mu, self.q_sqrt) else: K = self.kern.K(self.Z) + tf.eye(self.num_inducing, dtype=float_type) * settings.numerics.jitter_level if self.q_diag: KL = kullback_leiblers.gauss_kl_diag(self.q_mu, self.q_sqrt, K) else: KL = kullback_leiblers.gauss_kl(self.q_mu, self.q_sqrt, K) return KL
def KL(self): return gauss_kl_white(self.q_mu, self.q_sqrt)
def KL(self): all_mu = tf.concat([n.q_mu for n in self.nodes], 1) all_sqrt = tf.concat([n.q_sqrt for n in self.nodes], 2) return gauss_kl_white(all_mu, all_sqrt)