loopy_pearl_inf_engine.m
来自「Bayes网络工具箱」· M 代码 · 共 46 行
M
46 行
function engine = loopy_pearl_inf_engine(bnet, max_iter, tol, momentum)% LOOPY_PEARL_INF_ENGINE Pearl's algorithm (belief propagation) for graphs which may contain loops% engine = loopy_pearl_inf_engine(bnet, max_iter, tol, momentum)%% We run loopy propagation for a maximum of 'max_iter' iterations, or until% all the posteriors differ by less than 'tol', whichever occurs first.% 'max_iter' defaults to the num. nodes in the graph, which is an upper bound on the radius.% If the graph has no loops (undirected cycles), the results will be exact, because by then every% node is guaranteed to have felt the influence of all other nodes.% 'tol' defaults to 1e-3.% If 'momentum' is specified, the messages that are sent will be a convex combination of% the current and previous messages (m*old + (1-m)*new). Default: momentum = 0.% % For some theoretical work on the properties of this algorithm, see% - "Correctness of local probability propagation in graphical models with loops",% Yair Weiss, Neural Computation, 12 (1-41) 2000.% - "Correctness of belief propagation in Gaussian graphical models of arbitrary topology",% Y. Weiss and W. T. Freeman, TR UCB--CSD-99-1046 % For some experimental work, see% - "Loopy belief propagation for approximate inference: an empirical study",% K. Murphy, Y. Weiss and M. Jordan, UAI 99.%% SEE ALSO pearl_inf_engineN = length(bnet.dag);if nargin < 2, max_iter = N; endif nargin < 3, tol = 1e-3; endif nargin < 4, momentum = 0; endengine.max_iter = max_iter;engine.tol = tol;engine.momentum = momentum;% this is where we store stuff between enter_evidence and marginal_nodesengine.marginal = cell(1,N);engine.evidence = []; engine.msg = [];[engine.parent_index, engine.child_index] = mk_pearl_msg_indices(bnet);engine = class(engine, 'loopy_pearl_inf_engine', inf_engine(bnet));
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?