wolffd@0: % Make a DBN with the following inter-connectivity matrix wolffd@0: % 1 wolffd@0: % / \ wolffd@0: % 2 3 wolffd@0: % \ / wolffd@0: % 4 wolffd@0: % | wolffd@0: % 5 wolffd@0: % where all arcs point down. In addition, there are persistence arcs from each node to itself. wolffd@0: % There are no intra-slice connections. wolffd@0: % Nodes have noisy-or CPDs. wolffd@0: % Node 1 turns on spontaneously due to its leaky source. wolffd@0: % This effect trickles down to the other nodes in the order shown. wolffd@0: % All the other nodes inhibit their leaks. wolffd@0: % None of the nodes inhibit the connection from themselves, so that once they are on, they remain wolffd@0: % on (persistence). wolffd@0: % wolffd@0: % This model was used in the experiments reported in wolffd@0: % - "Learning the structure of DBNs", Friedman, Murphy and Russell, UAI 1998. wolffd@0: % where the structure was learned even in the presence of missing data. wolffd@0: % In that paper, we used the structural EM algorithm. wolffd@0: % Here, we assume full observability and tabular CPDs for the learner, so we can use a much wolffd@0: % simpler learning algorithm. wolffd@0: wolffd@0: ss = 5; wolffd@0: wolffd@0: inter = eye(ss); wolffd@0: inter(1,[2 3]) = 1; wolffd@0: inter(2,4)=1; wolffd@0: inter(3,4)=1; wolffd@0: inter(4,5)=1; wolffd@0: wolffd@0: intra = zeros(ss); wolffd@0: ns = 2*ones(1,ss); wolffd@0: wolffd@0: bnet = mk_dbn(intra, inter, ns); wolffd@0: wolffd@0: % All nodes start out off wolffd@0: for i=1:ss wolffd@0: bnet.CPD{i} = tabular_CPD(bnet, i, [1.0 0.0]'); wolffd@0: end wolffd@0: wolffd@0: % The following params correspond to Fig 4a in the UAI 98 paper wolffd@0: % The first arg is the leak inhibition prob. wolffd@0: % The vector contains the inhib probs from the parents in the previous slice; wolffd@0: % the last element is self, which is never inhibited. wolffd@0: bnet.CPD{1+ss} = noisyor_CPD(bnet, 1+ss, 0.8, 0); wolffd@0: bnet.CPD{2+ss} = noisyor_CPD(bnet, 2+ss, 1, [0.9 0]); wolffd@0: bnet.CPD{3+ss} = noisyor_CPD(bnet, 3+ss, 1, [0.8 0]); wolffd@0: bnet.CPD{4+ss} = noisyor_CPD(bnet, 4+ss, 1, [0.7 0.6 0]); wolffd@0: bnet.CPD{5+ss} = noisyor_CPD(bnet, 5+ss, 1, [0.5 0]); wolffd@0: wolffd@0: wolffd@0: % Generate some training data wolffd@0: wolffd@0: nseqs = 20; wolffd@0: seqs = cell(1,nseqs); wolffd@0: T = 30; wolffd@0: for i=1:nseqs wolffd@0: seqs{i} = sample_dbn(bnet, T); wolffd@0: end wolffd@0: wolffd@0: max_fan_in = 3; % let's cheat a little here wolffd@0: wolffd@0: % computing num. incorrect edges as a fn of the size of the training set wolffd@0: %sz = [5 10 15 20]; wolffd@0: sz = [5 10]; wolffd@0: h = zeros(1, length(sz)); wolffd@0: for i=1:length(sz) wolffd@0: inter2 = learn_struct_dbn_reveal(seqs(1:sz(i)), ns, max_fan_in); wolffd@0: h(i) = sum(abs(inter(:)-inter2(:))); % hamming distance wolffd@0: end wolffd@0: h