belprop_inf_engine_nostr.m

来自「贝叶斯网络的matlab实现。可以创建贝叶斯网络、训练模型」· M 代码 · 共 32 行

M
32
字号
function engine = belprop_inf_engine(fg, max_iter, momentum, tol, maximize)

if nargin < 2, max_iter = length(fg.G); end
if nargin < 3, momentum = 0; end
if nargin < 4, tol = 1e-3; end
if nargin < 5, maximize = 0; end

engine.fgraph = fg;
engine.max_iter = max_iter;
engine.momentum = momentum;
engine.tol = tol;
engine.maximize = maximize;

% store results computed by enter_evidence here
ndoms = length(fg.doms);
nvars = length(fg.vars);
engine.marginal_domains = cell(1, ndoms);

% to compute the marginal on each variable, we need to know which domain to marginalize
% so we represent each domain as a bit vector, and compute its (pre-evidence) weight
engine.dom_weight = [];

% engine.dom_bitv = sparse(ndoms, nvars);
% ns = fg.node_sizes;
% for i=1:ndoms
%   engine.dom_bitv(i, fg.doms{i}) = 1;
%   engine.dom_weight(i) = prod(ns(fg.doms{i}));
% end


engine = class(engine, 'belprop_inf_engine');

⌨️ 快捷键说明

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