jtree_dbn_fast_inf_engine.m

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

M
55
字号
function engine = jtree_dbn_fast_inf_engine(bnet, onodes, compiled)% JTREE_DBN_FAST_INF_ENGINE Like jtree_dbn, but with optimizations% function engine = jtree_dbn_fast_inf_engine(bnet, onodes, compiled)%% This is just like jtree_dbn, except the onodes argument (which specifies which nodes are observed in% every slice) is required. All the hidden nodes must always be discrete.% It is like BK in exact mode, except we exploit the fact that there is only one cluster.% Internally, this uses fast_jtree_onepass_inf_engine instead of jtree_inf_engine.% For a description of what we mean by 'fast', see the documentation for fast_jtree_inf_engine.if nargin < 3, compiled = []; endss = length(bnet.intra);clusters = { 1:ss };slice1 = (1:ss);slice2 = (1:ss)+ss;onodes2 = [onodes(:) onodes(:)+ss];ns = bnet.node_sizes_slice(:);ns(onodes) = 1;% 1 slice network to get startedbnet1 = mk_bnet(bnet.intra1, bnet.node_sizes_slice, bnet.dnodes, bnet.equiv_class(:,1));for i=1:max(bnet1.equiv_class)  bnet1.CPD{i} = bnet.CPD{i};endengine.sub_engine1 = jtree_onepass_fast_inf_engine(bnet1, slice1, onodes, [], compiled);[engine.fwd1.clq_ass_to_cluster, engine.fwd1.cluster_ndx, engine.fwd1.marg_cluster_ndx] = ...    mk_cluster_clq_ndx(engine.sub_engine1, ns, clusters, 1);[engine.fwd1.clq_ass_to_node, engine.fwd1.CPD_ndx] = mk_CPD_clq_ndx(engine.sub_engine1, ss, 1);engine.fwd.engine = jtree_onepass_fast_inf_engine(bnet, slice2, onodes2(:), {slice1}, compiled);[engine.fwd.clq_ass_to_cluster, engine.fwd.cluster_ndx, engine.fwd.marg_cluster_ndx] = ...    mk_cluster_clq_ndx(engine.fwd.engine, ns, clusters, 2);[engine.fwd.clq_ass_to_node, engine.fwd.CPD_ndx] = mk_CPD_clq_ndx(engine.fwd.engine, ss, 2);engine.back.engine = jtree_onepass_fast_inf_engine(bnet, slice1, onodes2(:), {slice2}, compiled);[engine.back.clq_ass_to_cluster, engine.back.cluster_ndx, engine.back.marg_cluster_ndx] = ...    mk_cluster_clq_ndx(engine.back.engine, ns, clusters, 2);[engine.back.clq_ass_to_node, engine.back.CPD_ndx] = mk_CPD_clq_ndx(engine.back.engine, ss, 2);% we call it sub_engine so it is compatible with the fast_bk methodsengine.sub_engine = jtree_fast_inf_engine(bnet, onodes2(:), { slice1, slice2 }, compiled);[engine.fb.clq_ass_to_cluster, engine.fb.cluster_ndx, engine.fb.marg_cluster_ndx] = ...    mk_cluster_clq_ndx(engine.sub_engine, ns, clusters, 2);[engine.fb.clq_ass_to_node, engine.fb.CPD_ndx] = mk_CPD_clq_ndx(engine.sub_engine, ss, 2);engine.cltables = [];engine.filter = [];engine.T = [];engine.onodes = onodes;engine = class(engine, 'jtree_dbn_fast_inf_engine', inf_engine(bnet));

⌨️ 快捷键说明

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