MATLAB Answers

How to design NN architecture to achieve max R2

1 view (last 30 days)
Sarah Mahmood
Sarah Mahmood on 10 Nov 2013
Commented: Sarah Mahmood on 13 Nov 2013
Hi all
I'm trying to design a NN for spoken word recognition and classification into two classes i.e Yes class and No class, I have already built a network but the result obtained was poor. I did a research on how to improve NN performance and I found posts form matlab answers regarding this issue explaining how to improve performance yet there still some things ambiguous if any one can help answering my question regarding the code below it would be much helpful for me
clc
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)
for h = 1:1:40 % e.g., 1:10 No. of Hidden nodes
for n = 1: 10 % e.g., 1:10 No. of Ntrials
net = patternnet(h);
net.divideFcn = 'dividetrain';
net.trainParam.goal = MSEgoal;
net.trainParam.min_grad = MinGrad;
[net tr ] = train(net,xtrn,ttrn);
bestepoch = tr.best_epoch;
R2(n,h) = 1 - tr.perf(bestepoch)/MSEtrn00;
end
end
R2 = R2
my questions are :- 1- when I increased the suggested no. of hidden nodes from 10 to 40, R2 increased why ?
2- through reading I found that R2 recommended to be ~=0.99 and what I got max(R2)=0.88 when I increase no. of hidden nodes, is what I did correct ?
3- R2 matrix sizes should be 10 rows and 40 columns, why am I getting R2(20,40) then ?
4- how to know which no. of hidden nodes achieve the required R2 ~=0.99 (i.e by using nodes=find(max(R2))) ?

  2 Comments

Sarah Mahmood
Sarah Mahmood on 10 Nov 2013
5- how can I interpret the obtained results listed below ??
MSEtrn00 =
0.2499
MSEgoal =
0.0025
MinGrad =
8.3293e-04
R2 =
Columns 1 through 7
0.0510 0.0262 0.1469 0.2012 0.2590 0.2515 0.3269
0.0512 0.1327 0.1762 0.2074 0.2243 0.2349 0.2524
0.0511 0.1339 0.1768 0.1702 0.2342 0.2510 0.2898
0.0513 0.1331 0.1788 0.1989 0.2793 0.2647 0.3156
0.0512 0.1329 0.1788 0.1944 0.2459 0.2558 0.3497
0.0446 0.0513 0.1794 0.1971 0.1987 0.2600 0.3408
0.0511 0.1332 0.1654 0.1660 0.2008 0.2442 0.2726
0.0512 0.0719 0.1219 0.1657 0.2238 0.2955 0.2607
0.0512 0.0511 0.1325 0.2079 0.2388 0.2491 0.3478
0.0511 0.1333 0.1341 0.1806 0.2245 0.2521 0.3092
0.0514 0.1329 0.1244 0.1936 0.2093 0.2483 0.2559
0.0507 0.1324 0.0773 0.1616 0.2043 0.2437 0.2503
0.0511 0.1333 0.1667 0.1645 0.2104 0.2614 0.3098
0.0253 0.0723 0.1478 0.1798 0.2244 0.2907 0.2552
0.0272 0.0512 0.1650 0.1994 0.2059 0.2634 0.2720
0.0513 0.1333 0.0545 0.1365 0.2094 0.2471 0.2854
0.0513 0.1336 0.0663 0.2035 0.1769 0.2304 0.2642
0.0511 0.0255 0.1664 0.1723 0.1960 0.2566 0.2324
0.0245 0.0741 0.0509 0.2125 0.2370 0.2264 0.2929
0.0513 0.0512 0.1648 0.2095 0.1698 0.2283 0.2812
Columns 8 through 14
0.3784 0.3783 0.3747 0.4760 0.4149 0.4594 0.4885
0.2925 0.3198 0.3889 0.4211 0.4723 0.4767 0.5240
0.3418 0.3874 0.3622 0.4354 0.4703 0.4173 0.5099
0.3138 0.3318 0.3811 0.4656 0.4606 0.4303 0.4952
0.2734 0.3312 0.3945 0.3368 0.4359 0.4346 0.5859
0.2986 0.4062 0.3383 0.4174 0.4243 0.4815 0.5082
0.3187 0.3804 0.3317 0.4319 0.4093 0.4080 0.5447
0.3073 0.3280 0.3325 0.4074 0.3839 0.4822 0.4074
0.3540 0.3158 0.4258 0.4527 0.4601 0.5131 0.5224
0.2621 0.3770 0.4247 0.4635 0.4714 0.5381 0.5243
0.3410 0.3455 0.3218 0 0 0 0
0.3139 0.3130 0.3369 0 0 0 0
0.3104 0.3765 0.4575 0 0 0 0
0.2807 0.3682 0.4168 0 0 0 0
0.3090 0.3893 0.4093 0 0 0 0
0.3118 0.3101 0.3461 0 0 0 0
0.3389 0.3421 0.4232 0 0 0 0
0.3371 0.3740 0.3875 0 0 0 0
0.3554 0.3531 0.4084 0 0 0 0
0.3472 0.3493 0.3788 0 0 0 0
Columns 15 through 21
0.5905 0.5428 0.5753 0.5791 0.6495 0.6433 0.7268
0.6183 0.5146 0.5238 0.6557 0.6618 0.7255 0.7286
0.5395 0.5937 0.5310 0.7010 0.5618 0.7205 0.5937
0.5999 0.5265 0.5948 0.6045 0.5992 0.6281 0.7204
0.5432 0.6031 0.5960 0.5978 0.5614 0.5618 0.6998
0.5129 0.6096 0.6008 0.5568 0.6701 0.6588 0.5948
0.5212 0.6177 0.5623 0.5323 0.6203 0.7217 0.7405
0.5804 0.5350 0.6387 0.6025 0.7043 0.7178 0.7157
0.5321 0.6094 0.5449 0.6150 0.6205 0.5939 0.7428
0.5778 0.4987 0.6760 0.6666 0.6298 0.7097 0.7101
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
Columns 22 through 28
0.7289 0.6744 0.7434 0.7084 0.7591 0.7182 0.7268
0.6855 0.7640 0.7022 0.7376 0.7100 0.7982 0.8380
0.7521 0.6881 0.7326 0.7402 0.7328 0.7832 0.7850
0.6875 0.7640 0.6874 0.7313 0.7043 0.7797 0.8231
0.7912 0.7063 0.7069 0.7017 0.7132 0.8154 0.8107
0.7225 0.7071 0.6893 0.7007 0.7755 0.7330 0.7820
0.7337 0.7061 0.7649 0.7184 0.7447 0.7202 0.7951
0.5491 0.6918 0.7493 0.7129 0.7601 0.7164 0.7741
0.6722 0.7637 0.7482 0.7137 0.7180 0.7129 0.7715
0.7427 0.6690 0.7211 0.7907 0.6955 0.7415 0.8020
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
Columns 29 through 35
0.8056 0.8171 0.7454 0.7711 0.8020 0.8318 0.8357
0.8043 0.8203 0.7821 0.7828 0.8373 0.7130 0.8296
0.7682 0.8111 0.7910 0.7613 0.8712 0.8289 0.7823
0.7227 0.7522 0.8514 0.8166 0.7888 0.7716 0.7622
0.7819 0.7796 0.7914 0.7827 0.7823 0.7873 0.7919
0.7893 0.7819 0.8017 0.7635 0.8405 0.8690 0.7882
0.7596 0.7138 0.7942 0.7922 0.8309 0.8403 0.7514
0.6935 0.8133 0.8022 0.7424 0.7927 0.7680 0.8517
0.7834 0.7512 0.8106 0.7422 0.7998 0.7821 0.7719
0.7989 0.7681 0.8012 0.7716 0.7964 0.8116 0.8403
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
Columns 36 through 40
0.8609 0.8221 0.8516 0.8126 0.8381
0.8207 0.8309 0.8559 0.7732 0.8413
0.7633 0.8514 0.8414 0.8019 0.8517
0.7524 0.7995 0.7825 0.8223 0.8222
0.7915 0.7709 0.8112 0.7723 0.7926
0.7818 0.8219 0.8378 0.7339 0.8125
0.7433 0.7922 0.7632 0.8121 0.8409
0.7726 0.7909 0.8209 0.8800 0.8124
0.8309 0.8217 0.8295 0.8780 0.6935
0.7912 0.7821 0.7926 0.8317 0.8221
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
>> x=max(R2)
x =
Columns 1 through 7
0.0514 0.1339 0.1794 0.2125 0.2793 0.2955 0.3497
Columns 8 through 14
0.3784 0.4062 0.4575 0.4760 0.4723 0.5381 0.5859
Columns 15 through 21
0.6183 0.6177 0.6760 0.7010 0.7043 0.7255 0.7428
Columns 22 through 28
0.7912 0.7640 0.7649 0.7907 0.7755 0.8154 0.8380
Columns 29 through 35
0.8056 0.8203 0.8514 0.8166 0.8712 0.8690 0.8517
Columns 36 through 40
0.8609 0.8514 0.8559 0.8800 0.8517
Sarah Mahmood
Sarah Mahmood on 13 Nov 2013
I'm getting R2=0.93 after many tests, is there anyone can help me on how to achieve R2~=0.99 ?? is it a must that R2~=0.99 ?

Sign in to comment.

Answers (0)

Sign in to answer this question.