Neural Network code

조회 수: 3 (최근 30일)
HARITHA
HARITHA 2011년 10월 6일
I have written a code in Matlab for neural network training and testing. But, it is not working as expected. I am training the network with input and target and testing it with test input and plotting the response against the actual response. mse is too high. The value of mse that I am getting is 15.4. Is there any mistake in the code? Can you take a look at the code and help me out !!
load a1.txt ( Input )
load a4.txt (Target)
load b1.txt (Test input)
load b4.txt (actual output)
P=[a1(1:2986,1)];
T=[a4(1:2986,1)];
a=[b1(1:2986,1)];
s=[b4(1:2986,1)];
[pn1,PS] = mapminmax(P');
[tn1,TS] = mapminmax(T');
[an1,AS]= mapminmax(a');
[sn1,SS]= mapminmax(s');
netnew1=newfit(pn1,tn1,[]);
[netnew1,tr1]=train (netnew1,pn1,tn1);
y2=sim(netnew1,an1);
y2_again = mapminmax('reverse',y2',TS);
plot(y2_again,'r');
hold;
plot(s);
d=(y2_again-s).^2;
mse1=mean(d);
Thanks & Regards,
Haritha Srinivasan

채택된 답변

Lucas García
Lucas García 2011년 10월 6일
Your code is basically creating a network with only one layer of neurons. With newfit this means that the network is trying to find the line that best fits the network.
However, your data might have a couple of nonlinearities (it doesn't necessarily have to be linear). Introducing a second layer of neurons will help to capture those situations. To do so, pick a number of neurons for your hidden layer (this depends on the complexity of your data). For example:
n = 25;
netnew1=newfit(pn1,tn1,n);
Now the response of your network should have been improved.

추가 답변 (1개)

HARITHA
HARITHA 2011년 10월 6일
Thanks for your reply.
I have never worked with Neural network toolbox before. I would like to know whether the code is right ? My objective is to train the network with input and target and when I test with a new set of input, it should predict the output values.
I would also like to know about how to reduce error value. I tried increasing the number of neurons. But I am still getting a mse value of 13.
It would be great if you could help me with this !!
Thanks, Haritha

카테고리

Help CenterFile Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by