hmm_states.py 文件源码

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

项目:siHMM 作者: Ardavans 项目源码 文件源码
def _messages_backwards_log_slow(trans_potential, init_potential, likelihood_log_potential,
                                     feature_weights, window_data):
        errs = np.seterr(over='ignore')
        Al = np.log(trans_potential)
        pil = np.log(init_potential)
        aBl = likelihood_log_potential
        nhs = trans_potential.shape[0]
        sequence_length = aBl.shape[0]
        betal = np.zeros((sequence_length, nhs * 2))
        giant_Al_pil = np.tile(np.vstack((np.tile(pil, (nhs,1)), Al )), (1,2))
        for t in xrange(betal.shape[0]-2,-1,-1):
            temp_constant = np.sum(feature_weights[:-nhs-1] * window_data[t+1,:]) + feature_weights[-1]
            temp_exp = temp_constant + feature_weights[-nhs-1:-1]
            temp_logaddexp = np.logaddexp(0, temp_exp)
            temp_log_linear = np.tile(temp_exp, 2) * np.repeat([0,1], nhs) - np.tile(temp_logaddexp, 2)

            np.logaddexp.reduce( giant_Al_pil + betal[t+1] +
                                 np.hstack((aBl[t+1], aBl[t+1])) +
                                 temp_log_linear
                                ,axis=1 ,out=(betal[t]))


        np.seterr(**errs)
        return betal
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号