gaussian_process.py 文件源码

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

项目:AutoGP 作者: ebonilla 项目源码 文件源码
def _build_cross_ent(self, weights, means, covars, kernel_chol):
        cross_ent = 0.0
        for i in xrange(self.num_components):
            sum_val = 0.0
            for j in xrange(self.num_latent):
                if self.diag_post:
                    # TODO(karl): this is a bit inefficient since we're not making use of the fact
                    # that covars is diagonal. A solution most likely involves a custom tf op.
                    trace = tf.trace(tf.cholesky_solve(kernel_chol[j, :, :],
                                                       tf.diag(covars[i, j, :])))
                else:
                    trace = tf.reduce_sum(util.diag_mul(
                        tf.cholesky_solve(kernel_chol[j, :, :], covars[i, j, :, :]),
                        tf.transpose(covars[i, j, :, :])))

                sum_val += (util.CholNormal(means[i, j, :], kernel_chol[j, :, :]).log_prob(0.0) -
                            0.5 * trace)

            cross_ent += weights[i] * sum_val

        return cross_ent
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号