How to test data on neural network toolbox after training it.

Hello. I am trying to make a speaker recognition system.
I have used neural network toolbox for training my data using back propogation method. I have stored voice samples (which says 'one')as data. Of the input I gave it took the 60% as train data, 20% as validation data and 20% as test data.The training is successful.
My question is that now how to test the data i.e. if i say the same word 'one' then it should tell that this sample matches with which one of the stored data.
I used y=sim(net,test) where test is the test data. This gives a value of 10.876 in my case.
What does this mean?
Kindly guide me. Thanks,
Nidhi

 Accepted Answer

Not enough information. Post your code.
How many classes? c = ?
How many input vectors per class?
What version of NNTBX?
Are you using patternnet or the obsolete newpr?
Convert the original c-class target matrix, target0, to c-dimensional unit matrix column form so that size(target) = [ c N ] and sum(target) = ones(1,N). Then class indices are obtained from
classind = vec2ind(target) % class indices
Use 'trainscg' and { 'tansig' 'logsig' }
[net tr ] = train(net,input,target);
tr = tr % reveals training details. Check it out!
newclassind = vec2ind(net(newinput))
Hope this helps.
Thank you for accepting my answer
Greg

5 Comments

Thanks Greg. Actually I am new to this NN toolbox. So, I searched internet and read tutorials and wrote this code .
Here there are 3 files. nidhi.mat contains 10 recorded voice of nidhisaying 'one'. and asit.mat contains 10 recorded voices of Asit saying 'one'.Test.mat contains just one recorded voice saying 'one'. The code is as follows:
load nidhi.mat
load asit.mat
load test.mat
fs=44100;
nid1=melcepst(n1,fs); nid2=melcepst(n2,fs); nid3=melcepst(n3,fs); nid4=melcepst(n4,fs); nid5=melcepst(n5,fs); nid6=melcepst(n6,fs); nid7=melcepst(n7,fs); nid8=melcepst(n8,fs); nid9=melcepst(n9,fs); nid10=melcepst(n10,fs);
nid1=nid1(:); nid2=nid2(:); nid3=nid3(:); nid4=nid4(:); nid5=nid5(:); nid6=nid6(:); nid7=nid7(:); nid8=nid8(:); nid9=nid9(:); nid10=nid10(:);
ast1=melcepst(as1,fs); ast2=melcepst(as2,fs); ast3=melcepst(as3,fs); ast4=melcepst(as4,fs); ast5=melcepst(as5,fs); ast6=melcepst(as6,fs); ast7=melcepst(as7,fs); ast8=melcepst(as8,fs); ast9=melcepst(as9,fs); ast10=melcepst(as10,fs);
ast1=ast1(:); ast2=ast2(:); ast3=ast3(:); ast4=ast4(:); ast5=ast5(:); ast6=ast6(:); ast7=ast7(:); ast8=ast8(:); ast9=ast9(:); ast10=ast10(:);
input=[nid1,nid2,nid3,nid4,nid5,nid6,nid7,nid8,nid9,nid10,ast1,ast2,ast3,ast4,ast5, ast6,ast7,ast8,ast9,ast10];
target=[10;10;10;10;10;10;10;10;10;10;01;01;01;01;01;01;01;01;01;01];
target=target';
net=newff(input,target,20,{},'trainrp');
[net,tr]=train(net,input,target);
test1=melcepst(test,fs);
t1=test1(:);
[y,tf]=sim(net,t1);
plotperf(tr);view(net);
In the above code the ast1, nid1 etc are 1020X1 matrix. The tr gives: tr =
trainFcn: 'trainrp'
trainParam: [1x1 struct]
performFcn: 'mse'
performParam: [1x1 struct]
divideFcn: 'dividerand'
divideParam: [1x1 struct]
trainInd: [3 5 6 7 9 10 11 13 14 15 18 19]
valInd: [2 12 16 20]
testInd: [1 4 8 17]
stop: 'Validation stop.'
num_epochs: 16
best_epoch: 10
goal: 0
states: {'epoch' 'time' 'perf' 'vperf' 'tperf' 'gradient' 'val_fail'}
epoch: [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
time: [1x17 double]
perf: [1x17 double]
vperf: [1x17 double]
tperf: [1x17 double]
gradient: [1x17 double]
val_fail: [0 1 2 0 0 1 0 1 0 0 0 1 2 3 4 5 6]
I know this is not a perfect code but I want a simple system which works. Please respond . I am using MATLAB 7.7.0(R2008b)NN toolbox version is V6.0.1
This is a bit urgent. You are the only person who has responded to NN questions asked by others also. So, I was waiting for response from you.
Nidhi
Hi Greg, I am waiting for reply from you. Thanks, Nidhi
Nidhi plz check ur target matrix; why 10 or 01;
it should be as:
target=[1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1];
The original 10 an 01 appears to work because the single applied input resulted in an answer that was closer to 10 than 1. In general, however take my previous advice for classifiers: unit matrix columns for targets, classind = vec2ind(t), { 'tansig' 'logsig' }, 'trainscg', [net tr] = train(net,x,t); y = sim(net,x); assignedclass=vec2ind(y); numerrs = sum(cassignedclass ~= classind)
If you take a look at the output from tr you will see that newff automatically divided the data randomly into trn/val/tst and the corresponding errors are given in tr. Therefore the tst errors give an unbiased estimate of predicted error on unseen nondesign data.
Also, y./sum(y) yields consistent estimates of the class posterior probabilities conditional on the input x, i.e., P(i | x ), i=1:c.
You didn't pursue all of the training information via
tr.trainParam
tr.performParam
tr.divideParam
tr.perf
tr.vperf
tr.tperf
tr.perf(10)
tr.vperf(10)
tr.tperf(10)

Sign in to comment.

More Answers (0)

Asked:

on 28 Dec 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!