Esempio n. 1
0
 def hmm_messages_backwards(self):
     betal = HMMStatesEigen._messages_backwards_log(
             self.hmm_bwd_trans_matrix,
             self.hmm_aBl)
     self._normalizer = np.logaddexp.reduce(
             np.log(self.hmm_bwd_pi_0) + betal[0] + self.hmm_aBl[0])
     return betal
Esempio n. 2
0
 def hmm_messages_backwards(self):
     betal = HMMStatesEigen._messages_backwards_log(
             self.hmm_bwd_trans_matrix,
             self.hmm_aBl)
     self._normalizer = np.logaddexp.reduce(
             np.log(self.hmm_bwd_pi_0) + betal[0] + self.hmm_aBl[0])
     return betal
Esempio n. 3
0
    def E_step(self):
        alphal = HMMStatesEigen._messages_forwards_log(self.hmm_trans_matrix, self.pi_0, self.aBl)
        betal = HMMStatesEigen._messages_backwards_log(self.hmm_trans_matrix, self.aBl)
        self.expected_states, self.expected_transcounts, self._normalizer = HMMStatesPython._expected_statistics_from_messages(
            self.hmm_trans_matrix, self.aBl, alphal, betal
        )

        # using these is untested!
        self._expected_ns = np.diag(self.expected_transcounts).copy()
        self._expected_tots = self.expected_transcounts.sum(1)

        self.expected_transcounts.flat[:: self.expected_transcounts.shape[0] + 1] = 0.0
Esempio n. 4
0
    def E_step(self):
        alphal = HMMStatesEigen._messages_forwards_log(self.hmm_trans_matrix,
                                                       self.pi_0, self.aBl)
        betal = HMMStatesEigen._messages_backwards_log(self.hmm_trans_matrix,
                                                       self.aBl)
        self.expected_states, self.expected_transcounts, self._normalizer = \
                HMMStatesPython._expected_statistics_from_messages(
                        self.hmm_trans_matrix,
                        self.aBl,
                        alphal,
                        betal)

        # using these is untested!
        self._expected_ns = np.diag(self.expected_transcounts).copy()
        self._expected_tots = self.expected_transcounts.sum(1)

        self.expected_transcounts.flat[::self.expected_transcounts.shape[0] +
                                       1] = 0.
Esempio n. 5
0
 def resample_hmm(self):
     betal = HMMStatesEigen._messages_backwards_log(
             self.hmm_bwd_trans_matrix,self.hmm_aBl)
     self.stateseq = HMMStatesEigen._sample_forwards_log(
             betal,self.hmm_bwd_trans_matrix,self.hmm_bwd_pi_0,self.hmm_aBl)
     self._map_states()