hmm_inf_engine.m

来自「Bayes网络工具箱」· M 代码 · 共 44 行

M
44
字号
function engine = hmm_inf_engine(bnet, onodes, oneslice)% HMM_INF_ENGINE Inference engine for discrete DBNs which uses the forwards-backwards algorithm.% engine = hmm_inf_engine(bnet, onodes, oneslice)%% 'onodes' specifies which nodes are observed; these must be leaves, and can be discrete or continuous.% The remaining nodes are all hidden, and must be discrete.% The hidden nodes must be persistent, i.e., they must have children in% the next time slice. In addition, they may not have any children within the current slice,% except to the observed leaves. In other words, the topology must be isomorphic to a standard HMM.%% If 'oneslice' = 1, we only compute the 1-slice marginals. (Default: compute 1 and 2-slice marginals.)% The 2-slice marginals take T*Q*Q space to store, where Q is the number of hidden states,% so if you are just interested in marginals on single nodes, use oneslice=1.%% For details on Hidden Markov Models, see% - "A tutorial on Hidden Markov Models and selected applications in speech recognition",%          L. Rabiner, Proc. IEEE 77(2):257--286, 1989.if nargin < 3, oneslice = 0; end[persistent_nodes, transient_nodes] = partition_dbn_nodes(bnet.intra, bnet.inter);assert(isequal(sort(onodes), transient_nodes));[engine.prior, engine.transmat] = dbn_to_hmm(bnet, onodes);engine.onodes = onodes;ss = length(bnet.intra);hnodes = mysetdiff(1:ss, onodes);engine.hnodes = hnodes;ns = bnet.node_sizes;onodes2 = [onodes onodes+ss];ns(onodes2) = 1;engine.node_sizes = ns;engine.bel = [];% This is where we will store the results between enter_evidence and marginal_nodesengine.one_slice_marginal = [];engine.two_slice_marginal = [];engine.oneslice = oneslice;engine = class(engine, 'hmm_inf_engine', inf_engine(bnet));

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?