pep_models.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:geepee 作者: thangbui 项目源码 文件源码
def update_posterior(self, x_train=None, new_hypers=False):
        """Summary

        Returns:
            TYPE: Description
        """
        # compute the posterior approximation
        if new_hypers and x_train is not None:
            Kfu = compute_kernel(2*self.ls, 2*self.sf, x_train, self.zu)
            KuuinvKuf = np.dot(self.Kuuinv, Kfu.T)
            self.Kfu = Kfu
            self.KuuinvKuf = KuuinvKuf
            self.Kff_diag = compute_kernel_diag(2*self.ls, 2*self.sf, x_train)

        KuuinvKuf_div_var = np.einsum('an,nd->dan', self.KuuinvKuf, 1.0 / self.variances)
        T2u = np.einsum('dan,bn->dab', KuuinvKuf_div_var, self.KuuinvKuf)
        T1u = np.einsum('bn,nd->db', self.KuuinvKuf, self.means / self.variances)
        Vinv = self.Kuuinv + T2u
        self.Suinv = Vinv
        self.Su = np.linalg.inv(Vinv)
        self.mu = np.einsum('dab,db->da', self.Su, T1u)
        self.gamma = np.einsum('ab,db->da', self.Kuuinv, self.mu)
        self.beta = self.Kuuinv - np.einsum('ab,dbc->dac', 
            self.Kuuinv,
            np.einsum('dab,bc->dac', self.Su, self.Kuuinv))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号