Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Data division problem in neural network

Subject: Data division problem in neural network

From: srishti

Date: 23 Apr, 2013 14:50:09

Message: 1 of 4

Hello,
           I am using neural network pattern recognition for classification purpose.My problem is I am not getting whether for input and target both I have to write individual command "trainInd,valInd,testInd] = divideind(Q,trainInd,valInd,testInd)"
and if yes then how to define parameters(net.divideparm)? I have written the following code.I have read the documentation but I am not able to clear my doubt. Please help.


s = RandStream('mcg16807','Seed', 0);
RandStream.setDefaultStream(s)
x=input; % size of x is 10x70
t=target;% size of t is 3x70
net = patternnet(22);
net.divideFcn='divideInd';
[trainInd,valInd,testInd] = divideind(x,1:20,35:45,54:65);
 net.divideParam.trainInd = trainInd
 net.divideParamvalInd = valInd
 net.divideParam.testInd = testInd
 net= train(net,x,t);

Subject: Data division problem in neural network

From: Greg Heath

Date: 27 Apr, 2013 22:17:09

Message: 2 of 4

"srishti" wrote in message <kl6731$8a8$1@newscl01ah.mathworks.com>...
> Hello,
> I am using neural network pattern recognition for classification purpose.My problem is I am not getting whether for input and target both I have to write individual command "trainInd,valInd,testInd] = divideind(Q,trainInd,valInd,testInd)"
> and if yes then how to define parameters(net.divideparm)? I have written the following code.I have read the documentation but I am not able to clear my doubt. Please help.
>
> s = RandStream('mcg16807','Seed', 0);
> RandStream.setDefaultStream(s)
> x=input; % size of x is 10x70
> t=target;% size of t is 3x70

[I N ] = size(x) % [ 10 70 ]
[O N ] = size(t) % [ 3 70 ]

% The default division ratios are 0.7/0.15/0.15
Ntst =round(0.15*N) % 11
Nval = Ntst % 11
Ntrn = N-2*Ntst % 48
trainind = 1:Ntst
valind = Ntrn+1:Ntrn+Nval
tstind = Ntrn+Nval+1:N
Ntrneq = Ntrn*O % 144 No. of training equations

% No. of unknown weights
% Nw = (I+1)*H+(H+1)*O
% For more equations than unknowns H <= Hub

Hub= -1+ ceil( (Ntrneq -O) / (I+O+1) ) % 10

> net = patternnet(22);

No. Choose H by trial and error for 0 <= H <= 10

H = 5 % Prefer a loop H = 0:1:10
net = patternnet(H); % remove semicolon to see default parameter values

> net.divideFcn='divideInd';
> [trainInd,valInd,testInd] = divideind(x,1:20,35:45,54:65);

Replace x with N
Not sure why you are not using all of the data
[trainInd,valInd,testInd] = divideind(N,trnind,valind,tstind);

> net.divideParam.trainInd = trainInd
> net.divideParamvalInd = valInd
> net.divideParam.testInd = testInd
> net= train(net,x,t);

[ [ net tr y ] = train(net,x,t); % y is output

net = net % See all of the input parameters

tr = tr % See all of the training results.

Hope this helps.

Greg

Subject: Data division problem in neural network

From: srishti

Date: 28 Apr, 2013 14:29:10

Message: 3 of 4

Sir thank you so much for your reply..
 Sir u wrote that number of H should vary between 0 and 10 ,but when i vary H between 0 and 10 i get maximum accuracy of 77.1% . But when I use H=49 I get an accuracy of 88.6%. Can I use H=49 ?

Subject: Data division problem in neural network

From: Greg Heath

Date: 29 Apr, 2013 02:29:09

Message: 4 of 4

"srishti" wrote in message <kljbnm$3t3$1@newscl01ah.mathworks.com>...
> Sir thank you so much for your reply..
> Sir u wrote that number of H should vary between 0 and 10 ,but when i vary H between 0 and 10 i get maximum accuracy of 77.1% . But when I use H=49 I get an accuracy of 88.6%. Can I use H=49 ?

Of course you can use it. The question is: Is the result a valid estimate for data that was neither used for training or validation?

I don't believe it is. I believe you overtrained an overfit (No. of unknown weights much larger than the number of training equations) net. However, only you can prove it.

Can you repeat the estimation on nontraining/nonvalidation data if you loop over
10 separate designs using 10 different random sets of initial weights?

If the answer is yes, please post your code.

Greg

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us