Help meeeee.....through this prblm.

hai, i want a program on three input and two output neural network with two hidden layers(1st hidden layer should have 3 nodes and 2nd layer 2 nodes... )
this program help me in solving so many things....so ,pls send the prgm as early as possible...
thank you,

2 个评论

Usually there is no good reason to use more than one hidden layer. Similarly, there is usually no good reason to not use as many default parameters as possible.
What version of the NNtoolbox are you using? There are currently two versions of NEWFF, and one each of FEEDFORWARDNET and FITNET.
See samples of code in the Documentation, the Newsgroup, and Answers.
Hope this helps.
Greg
What type of net do you need?
Regression (curve fitting) , Classification, or Time-Series Prediction?
Greg

请先登录,再进行评论。

回答(2 个)

Greg Heath
Greg Heath 2012-2-14

0 个投票

The syntax to create a feedforward network with :
- 3 unit of inputs - hidden1 : 3 nodes - hidden2 : 2 nodes - 2 unit of outputs is shown below :
net = newff(PR,[3 3 2 2],{'logsig','logsig','logsig','logsig'},'traingda');
INCORRECT. THIS SPECIFIES 3 HIDDEN LAYERS. ONLY 1 IS NEEDED.
NOTE: I AM USING ALL CAPS FOR CLARIFICATION. DO NOT USE ALL CAPS IN YOUR CODE!
EITHER STANDARDIZE INPUTS TO ZERO-MEAN/UNIT-VARIANCE OR, IF PHYSICAL OR MATHEMATICAL BOUNDS ARE KNOWN, NORMALIZE TO THE BOUNDED BIPOLAR INTERVAL [-1,1].
FOR REGRESSION STANDARDIZE OUTPUTS.
USE 1 HIDDEN LAYER
USE TANSIG FOR HIDDEN NODES (DEFAULT)
USE PURELIN FOR THE OUTPUT NODES (DEFAULT)
USE TRAINLM FOR TRAINING (DEFAULT)
IF Pn IS THE NORMALIZED INPUT MATRIX AND Tn IS THE NORMALIZED OUTPUT MATRIX,
[ I N ] = SIZE(Pn)
[O N ] = SIZE( Tn)
FOR I-H-O NODE TOPOLOGY
NET = NEWFF(MINMAX(Pn), [H O]); % OLD VERSION
NET = NEWFF(Pn,Tn,H); % NEWER VERSION
NET = FITNET(H); % NEWEST VERSION
SEE THE DOCUMENTATION EXAMPLES ...(E.G., DOC FITNET)
In the next step you need to train this network. You can use train command from the toolbox.
For stopping criteria you can set the maximum number of epochs : 1500 and performance goal : 0
net.trainParam.epochs = 1500;
net.trainParam.goal = 0;
IF YOU USE TRAINLM THE DEFAULT IS 100 EPOCHS. INCREASE IF NEEDED
A PRACTICAL GOAL IS MEAN(VAR(Tn'))/100
net = train(net,pa,t);
Then to simulate the output, you can use sim command.
[NET TR Y] = TRAIN(...) AUTOMATICALLY YIELDS THE OUTPUT Y
This code below is just an example for the complete code :
p = [4 3 4 1 3 2]; t = eye(2);
COLUMNS OF EYE TYPICALLY ONLY USED FOR CLASSIFICATION.
pa = (p-min(p(:))) / (max(p(:))-min(p(:)));
PR = [0 1;0 1;0 1];
NOT RECOMMENDED. NORMALIZE EACH ROW SEPARATELY. EITHER STANDARDIZE OR NORMALIZE TO [-1 ,1]
-----SNIP
GREG

1 个评论

Sir,I need matlab code.....this code also helps me but....for me classification of outputs is needed.Below this i am sending the code which i had written,,,and rectify the classification pblm...
thank u

请先登录,再进行评论。

Hello sir, this is the code i had implemented for cancer dataset,her i am using 2 hiddenlayers,,,,,,but here i am not able to classify(classification of outputs).So ,pls solve this error and if modification is needed modify it,and let me know what the error is,,,,,,
I am so eagrly waiting for u r reply.Pls send the suitable suggestion as early as possible.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%...............
tpat = xlsread('cancer.xls');
tpat(:,2:end) = zscore(tpat(:,2:end));
ni=length(tpat(1,:))-1;%no of inputs
no=2;%no of output
ntmax=length(tpat(:,1));%no of patterns
nh=4;%no of neurons in 1st hidden layer
nl=3;%no of neurons in 2nd hidden layer
itmax=500;%maximum iterations
eta=5;%learning rate
wh=rand(nh,ni);
wl=rand(nl,nh)-0.5;
wo=rand(2,nl)-0.5;
bh=rand(1,nh)-0.5;
bl=rand(1,nl)-0.5;
bo=rand(1,2)-0.5;
%training routine..........
for it = 1:itmax
for nt = 1:ntmax
x = tpat(nt,2:ni+1);
t = tpat(nt,1);
neth = (wh*x')'+bh;
h=1./(1+exp(-neth));
neth1 = (wl*h')'+bl;
k=1./(1+exp(-neth1));
nety = (wo*k')'+bo;
y=1./(1+exp(-nety));
%Backward Propagation Starts..............
e=eta*(t-y).*y.*(1-y);
dbo=e;
dwo=e'*k;
dbl=(e*wo).*k.*(1-k);
dwl=dbl'*h;
dbh=(dbl*wl).*h.*(1-h);
dwh=dbh'*x;
bo=bo+dbo;
bl=bl+dbl;
bh=bh+dbh;
wo=wo+dwo;
wl=wl+dwl;
wh=wh+dwh;
end
for nt = 1:ntmax
x = tpat(nt,2:ni+1);
t = tpat(nt,1);
neth = (wh*x')'+bh;
h=1./(1+exp(-neth));
neth1 = (wl*h')'+bl;
k=1./(1+exp(-neth1));
nety = (wo*k')'+bo;
y=1./(1+exp(-nety));
ee(nt,:)=t-y;
end
eee(it,:)=sum(ee(nt,:).^2)/2/ntmax;
plot(eee);drawnow;
end
toc
%testing routine
ntmaxTest=ntmax;
for nt = 1:ntmaxTest
x = tpat(nt,2:ni+1);
t = tpat(nt,1);
neth = (wh*x')'+bh;
h=1./(1+exp(-neth));
neth1 = (wl*h')'+bl;
k=1./(1+exp(-neth1));
nety = (wo*k')'+bo;
yy(nt,:) = 1./(1+exp(-nety));
end
tpatt=[tpat,yy]
%plot xor input data to see
% figure,plot(tpatt(2:3,1),tpatt(2:3,2),'*r')
% hold on,,plot(tpatt(1:3:4,1),tpatt(1:3:4,2),'o')
plot(yy,'o'); hold on; plot(tpat(:,1),'r*')
%%%%%%%%%%%%%%%%%..................

3 个评论

I don't mind helping you to use the NN Toolbox. However,
not using the toolbox and expecting me to inspect a zillion lines
of uncommented code is over the top.
Greg.
Basically i supposed to use this code format..so if take some patience see my code...help mee through this hurdle i would be so glad to you....
Using that code format does not prevent you from adding useful comments.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Deep Learning Toolbox 的更多信息

提问:

2012-2-13

编辑:

2013-10-23

Community Treasure Hunt

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

Start Hunting!

Translated by