def _set_startprob(self, startprob):
if startprob is None:
startprob = np.ones(shape=(self.n_partial_states, self.n_hidden_states)) / self.n_hidden_states
else:
startprob = np.asarray(startprob, dtype=np.float)
# check if there exists a component whose value is exactly zero
# if so, add a small number and re-normalize
if not np.alltrue(startprob):
startprob = normalize(startprob, axis=1)
if len(startprob) != self.n_partial_states:
raise ValueError('startprob must have length n_partial_states')
if not np.allclose(np.sum(startprob, axis=1), 1.0):
raise ValueError('startprob must sum to 1.0')
self._log_startprob = np.log(np.asarray(startprob).copy())
评论列表
文章目录