wilk916 / bnt

Automatically exported from code.google.com/p/bnt
0 stars 0 forks source link

got issue when change rate training #41

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. This is main code :  main.m

addpath(genpath('bnt/'));

numberClass = 40;
numberPattern = 10;

load xechancFace xechancFace;
[classNode, ~] = size(xechancFace.dataTest);
load dagTanFace dagTanFace;

node_sizes = max(xechancFace.dataTrain,[],2);%node_sizes(i) is the size of node 
i

[n, ~] = size(xechancFace.dataTrain);

dataTrain = num2cell(xechancFace.dataTrain);
dataTest = num2cell(xechancFace.dataTest);
dataTest(classNode,:) = {[]}; % remove classNode

init_bnet = mk_bnet(dagTanFace,node_sizes);

for i=1:n
    init_bnet.CPD{i} = tabular_CPD(init_bnet,i);
end

% training
bnet = learn_params(init_bnet,dataTrain);

% testing
sizeTest = size(dataTest,2);
prob = zeros(sizeTest,node_sizes(classNode));
%Computes the probabilities given to the solutions in Data 
engine = jtree_inf_engine(bnet);

for i=1:sizeTest
    [engine,loglik] = enter_evidence(engine, dataTest(:,i));
    marg = marginal_nodes(engine, classNode);
    prob(i,:) = marg.T;
end

2. rate train/test is 7/3
 I got this error
Index exceeds matrix dimensions.

Error in discrete_CPD/convert_to_table (line 13)
T = CPT(index{:});

Error in discrete_CPD/convert_to_pot (line 20)
   T = convert_to_table(CPD, domain, evidence);

Error in jtree_inf_engine/enter_evidence (line
57)
      pot{n} = convert_to_pot(bnet.CPD{e},
      pot_type, fam(:), evidence);

Error in C43bNTrainingTabular (line 38)
    [engine,loglik] = enter_evidence(engine,
    dataTest(:,i));

What is the expected output? What do you see instead?
why i got this error ? and why loglik always 0

What version of the product are you using? On what operating system?

matlab version 2013a , window 8.1

Please provide any additional information below.

Original issue reported on code.google.com by hoangvan...@gmail.com on 4 Aug 2015 at 2:14