I don't Know why my neural network doesn't give good results

1 visualizzazione (ultimi 30 giorni)
I tried to build NN for spoken word classification I followed many approaches discussed here in th group, yet the results terrible I got only ~65% correct classification, I don't what wrong I'm so desperate.
I appreciate any help or notice on my code or the approach I followed
load yesClass2;
load noClass2;
yes2=1*ones(1,199);
no2=zeros(1,208);
InData=[yesClass2 ;noClass2];
InData=InData';
TarData=[yes2 no2];
xtrn=InData;
ttrn=TarData;
[ I N ] = size( xtrn ) % [ 5 407 ]
[ O N ] = size( ttrn ) % [ 1 407 ]
MSEtrn00 = mean(var(ttrn',1))
MSEgoal = MSEtrn00/100
MinGrad = MSEtrn00/300
%rng(0)
net4 = patternnet(58,'trainlm');
net4.divideFcn = 'dividetrain';
net4.trainParam.goal = MSEgoal;
net4.trainParam.min_grad = MinGrad;
[net4 tr ] = train(net4,xtrn,ttrn);
bestepoch = tr.best_epoch;
R2 = 1 - tr.perf(bestepoch)/MSEtrn00;
save net4 net4
  1. I chose No. of hidden nodes 58 based on max. R2 achieved
  2. max. R2 = 0.9
  3. I attached confusion matrix for complete data set used for training and for divided data set into 70% training, 30% validation and 30% testing
  2 Commenti
Sarah Mahmood
Sarah Mahmood il 14 Nov 2013
Modificato: Image Analyst il 24 Ago 2018
I forgot to mention
MSEtrn00 =
0.2499
MSEgoal =
0.0025
MinGrad =
8.3293e-04
This is the first confusion matrix
and this is the second confusion matrix.
Greg Heath
Greg Heath il 25 Ago 2018
Modificato: Greg Heath il 25 Ago 2018
Totally confusing post
=====================
Came back later and struggled through. I understand now.
Next time you post code please explain exactly what you are doing and why.
In particular 58 hidden nodes is overfitting when the data is divided.
Unfortunately, the MATLAB confusion matrices are not very easy to understand.
I have posted a better code for understanding (might be in the NEWSGROUP).
Greg

Accedi per commentare.

Risposta accettata

Greg Heath
Greg Heath il 29 Nov 2013
This is a classic case of overtraining an overfit net:
DIVIDETRAIN:
Nw = (5+1)*58+(58+1)*1 = 348 + 59 = 407 % Unknown weights
Ntrneq = 407*1 = 407 % Equations
The no overfitting condition Ntrneq >> Nw is readily violated
DIVIDERAND:
Ntrneq = 407 -2*round(0.15*407) = 285 < 407
  1 Commento
KAE
KAE il 24 Ago 2018
Modificato: KAE il 24 Ago 2018
Here are Greg's calculations with extra comments to help other learners,
% Number of rows: number of features. Number of columns: number of samples.
[ I N ] = size( xtrn ) % Size of network inputs
[ O N ] = size( ttrn ) % Size of network targets
% H is number of neurons in hidden layer, here 58
fractionTrain = 0.15; % Fraction of data used as training examples.
% 0.15 is the default, which is assumed here
fractionValid = 0.15; % Fraction of data used as validation examples
% 0.15 is the default
Ntrn = N - round(fractionTrain*N + fractionValid*N); % Number of training examples
Ntrneq = Ntrn*O; % Number of training equations
Nw = (I+1)*H + (H+1)*O; % Number of unknown weights
% Since we want Ntrnreq>>Nw, we could require that Nw<Ntrneq/10
% But it's not, so we are overfitting
% Must either get more data (training examples), or
% simplify our model (smaller H)
The plot here is helpful for understanding overfitting.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by