LocalStepSingleDoc.py 文件源码

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

项目:bnpy 作者: bnpy 项目源码 文件源码
def calcELBO_SingleDocFromSparseResp(
        spResp_d, ElogLik_d, wc_d, alphaEbeta):
    ''' Calculate single document contribution to the ELBO objective.

    This isolates all ELBO terms that depend on local parameters of this doc.

    Returns
    -------
    L : scalar float
        value of ELBO objective, up to additive constant.
        This constant is independent of any local parameter attached to doc d.
    '''
    DocTopicCount_d = wc_d * spResp_d # Sparse multiply
    theta_d = DocTopicCount_d + alphaEbeta
    R_d = spResp_d.toarray()
    wR_d = wc_d[:, np.newaxis] * R_d
    L_alloc = np.sum(gammaln(theta_d))
    L_data = np.sum(wR_d * ElogLik_d)
    RlogR = np.sum(wR_d * np.log(R_d + 1e-100))
    return L_alloc + L_data - RlogR
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号