how to improve performance of a neural network
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi every body
I am working on a code for retraining a NN to study its performance. My problem is that the performance of the network is low. Is there any thing I can do to improve its performance other than changing divideparam? Is there any problem with my code? Thank you very much for your help:
[
x,t]=bodyfat_dataset;
numtrain=20;
net=feedforwardnet(5);
ytr00=mean(t,2);
rng(0);
for i=1:numtrain
[NN{i} tr{i} y{i}]=train(net,x,t);
x_val{i}=x(:,tr{i}.valInd);
t_val{i}=t(tr{i}.valInd);
x_test{i}=x(:,tr{i}.testInd);
t_test{i}=t(tr{i}.testInd);
MSEval00(i)=mse(t_val{i}-ytr00);
MSEtst00(i)=mse(t_test{i}-ytr00);
y_val{i}=NN{i}(x_val{i});
y_tst{i}=NN{i}(x_test{i});
MSEval(i)=mse(net, t_val{i},y_val{i});
MSEtest(i)=mse(net, t_test{i},y_tst{i});
R2val(i)=1-MSEval(i)/ MSEval00(i);
R2tst(i)=1-MSEtest(i)/ MSEtst00(i);
end
댓글 수: 1
Meva
2014년 1월 3일
Use cell structure before for loops. So that you can accelerate the performance and matlab will locate the values before loop.
채택된 답변
Greg Heath
2014년 1월 3일
편집: Greg Heath
2014년 1월 3일
% close all, clear all, clc, tic
% [x,t]=bodyfat_dataset;
% numtrain=20;
% net=feedforwardnet(5);
1. Not enough hidden nodes
% ytr00=mean(t,2);
2. Should use yval00 and ytst00 inside loop
% rng(0);
% for i=1:numtrain
3. In a loop must EXPLICITLY initialize weights using configure
% [NN{i} tr{i} y{i}]=train(net,x,t);
4. Only need to index R2val and R2tst
% x_val{i}=x(:,tr{i}.valInd);
% t_val{i}=t(tr{i}.valInd);
% x_test{i}=x(:,tr{i}.testInd);
% t_test{i}=t(tr{i}.testInd);
% MSEval00(i)=mse(t_val{i}-ytr00);
% MSEtst00(i)=mse(t_test{i}-ytr00);
See comment 2
% y_val{i}=NN{i}(x_val{i});
% y_tst{i}=NN{i}(x_test{i});
5. Can get yval and ytst from y using indices
% MSEval(i)=mse(net, t_val{i},y_val{i});
% MSEtest(i)=mse(net, t_test{i},y_tst{i});
% R2val(i)=1-MSEval(i)/ MSEval00(i);
% R2tst(i)=1-MSEtest(i)/ MSEtst00(i);
% end
% summary = [ R2val' R2tst' ]
6. The unbiased generalization performance estimate is obtained from R2tst when R2val is a max.
% [R2valmax ivalmax] = max(R2val) % [ 0.77494 12 ]
% R2gen = R2tst(ivalmax) % [ 0.69092 ]
% toc % ~ 9 sec
Hope this helps.
Thank you for formally accepting my answer
Greg
댓글 수: 3
Greg Heath
2014년 1월 3일
편집: Greg Heath
2014년 1월 3일
ytrn00, yval00 and ytst00 should be obtained inside the loop from mean(t(tr.trainInd),2). In this case of a scalar output, t, they are all equal scalars. Otherwise, repmat has to be used to get the correct number of columns Ntrn, Nval and Ntst, respectively.
The error caused by using y00 instead of ytrn00 should decrease rapidly as min(Ntrn,Nval,Ntst) increases.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!