try to simulate neural network in Matlab by myself

조회 수: 2 (최근 30일)
alireza mirzargar
alireza mirzargar 2012년 7월 30일
hi every one, i tried to create a neural network that estimate y = x ^ 2 so i create a fitting neural network and give some sample for input and out put. then i tried to come this network to c++. but the result is different i tried to find why this happened. i wrote this command in matlab :
purelin(net.LW{2}*tansig(net.IW{1}*in+net.b{1})+net.b{2})
and the result was 16.0828 for : in = 3
my network has 2 neurons. and other information are :
net.IW : 0.344272596370387 0.344111217766824
net.LW : 31.7635369693519 -31.8082184881063
b : -1.16610230053776 1.16667147712026
b2 : 51.3266249426358
so is any body have any idea why this has happened? thank you

채택된 답변

Greg Heath
Greg Heath 2012년 7월 31일
I used fitnet(2) with all defaults except for
rng(0)
net.trainparam.goal = MSE00/100;
where MSE00 is the mse for the constant mean value (=1704) output model.
It converged resulting in
Nepochs = tr.epoch(end) % 5
NMSEtrn = tr.perf(end)/MSE00 % 0.0018431
NMSEval =tr.vperf(end)/MSE00 % 0.00068653
NMSEtst = tr.tperf(end)/MSE00 % 0.0016467
whereas
y3 = net(3) % 70.409 (instead of 3^2 = 9)
sqerr3 = (y3-3^2)^2 % 3771.1
Nsqerr3 = sqerr3/MSE00 % 0.0016237
So, to get a good feel for how well the net is performing
look at the normalized test set NMSEtst.
Hope this helps.
Greg
  댓글 수: 3
alireza mirzargar
alireza mirzargar 2012년 8월 5일
thank you, but i think you did'nt understand my question well. i know we must have some pre-process and post-proccess. i have problem in normalize data, especially out put scale out. for input we can use mapminmaxfunction. but i don't have any idea about out put processor.
Greg Heath
Greg Heath 2012년 8월 8일
All of the MLP functions (newff,newfit,newpr,fitnet,patternet,feedforwardnet)
AUTOMATICALLY use mapminmax. Therefore, you do not have to worry about it
unless you either want no normalization or standardization(zero-mean/unit-std)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Greg Heath
Greg Heath 2012년 7월 31일
What was the range of x for training? How many input values? What random number seed? What training algorithm? What stopping rule? How many values of hidden nodes did you try? How many trials of weight initialization for each value of H? Where are the tabulations of MSE for training, validation and test sets?
For the design with the lowest MSEval, Tabulate x, t, y, e=t-y.
For useful examples, search
heath newff close clear Ntrials
Use fitnet instead of the obsolete newff.
  댓글 수: 3
Greg Heath
Greg Heath 2012년 7월 31일
Why didn't you just enter
input = [0:71,-1:-1:-71} ;
target = input.^2 ; % Reserve "output" for net(input)
N =343
How, exactly, did you obtain the weights?
Post your code.
What is the NMSE = MSE/MSE00 or R^2 =1-NMSE for train, val & test?
alireza mirzargar
alireza mirzargar 2012년 7월 31일
In fact i'm a new user in Matlab so i don't have the information that you want, for example i don;t know what is N? i go to tool box of neural network in fitting tool, then i set the inputs and outputs. and then trains the datas. so i don't know how can i find NMSE = MSE/MSE00 or R^2 = 1 - NMSE or others. so Matlab sets the weights. and i found them with net.IW(1) and net.LW(2) thank you

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by