Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/bnt/examples/static/Brutti/Sigmoid_Belief.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 % Sigmoid Belief Net | |
2 | |
3 clear all | |
4 clc | |
5 dum1 = 1; | |
6 dum2 = 2; | |
7 dum3 = 3; | |
8 Q1 = 4; | |
9 Q2 = 5; | |
10 Y = 6; | |
11 dag = zeros(6,6); | |
12 dag(dum1,[Q1 Y]) = 1; | |
13 dag(dum2, Q2)=1; | |
14 dag(dum3, [Q1 Q2])=1; | |
15 dag(Q1,[Q2 Y]) = 1; | |
16 dag(Q2, Y)=1; | |
17 | |
18 ns = [2 2 3 3 4 3]; | |
19 dnodes = [1:6]; | |
20 bnet = mk_bnet(dag,ns, dnodes); | |
21 | |
22 rand('state',0); randn('state',0); | |
23 n_iter=10; | |
24 clamped=0; | |
25 | |
26 bnet.CPD{1} = tabular_CPD(bnet, 1); | |
27 bnet.CPD{2} = tabular_CPD(bnet, 2); | |
28 bnet.CPD{3} = tabular_CPD(bnet, 3); | |
29 % CPD = dsoftmax_CPD(bnet, self, dummy_pars, w, b, clamped, max_iter, verbose, wthresh,... | |
30 % llthresh, approx_hess) | |
31 bnet.CPD{4} = softmax_CPD(bnet, 4, 'discrete', [1 3]); | |
32 bnet.CPD{5} = softmax_CPD(bnet, 5, 'discrete', [2 3]); | |
33 bnet.CPD{6} = softmax_CPD(bnet, 6, 'discrete', [1 4]); | |
34 | |
35 T=5; | |
36 cases = cell(6, T); | |
37 cases(1,:)=num2cell(round(rand(1,T)*1)+1); | |
38 %cases(2,:)=num2cell(round(rand(1,T)*1)+1); | |
39 cases(3,:)=num2cell(round(rand(1,T)*2)+1); | |
40 cases(4,:)=num2cell(round(rand(1,T)*2)+1); | |
41 %cases(5,:)=num2cell(round(rand(1,T)*3)+1); | |
42 cases(6,:)=num2cell(round(rand(1,T)*2)+1); | |
43 | |
44 engine = jtree_inf_engine(bnet); | |
45 | |
46 [engine, loglik] = enter_evidence(engine, cases); | |
47 | |
48 disp('learning-------------------------------------------') | |
49 [bnet2, LL2, eng2] = learn_params_em(engine, cases, n_iter); |