|
• Rebuild "traingdm" algorithm
I perform it using somecodes as follows but I think it has some problems with the error E because I can't compute the sum using cell E. But I can't change it into a matrix.please, help me:
innum= input(' innum = ');
hidnum= input(' hidnum = ');
samnum= input ('samnum =');
x= rand ( innum,1);
Wu = rand (hidnum,innum);
Wy = rand (1, hidnum);
E = {[0],[0]};
bu= rand(hidnum,1);
by= rand(1,1);
%(initupdate)
eta = input(' eta= '); %eta= learning coefficient
alpha = input(' alpha= '); %alpha = momentum coefficient
deltaW= Wu;
%-----------------------------------------------
%main
dem = 0; %bien dem nay dung de dat lam epoch
for i = 1: samnum,
%samnum(i)
d = dlearn(i,:);
x = xlearn(i,:)';
%(compute for network)
E{1,1} = E{1,2};
NETu = Wu*x-bu;
u = logsig(NETu);
NETy = Wy*u-by;
y= purelin(NETy);
E{1,2} = d-y;
%derivativeE(W)
deriv =[];
deltaE = E{1,2}-E{1,1};
for i = 1:hidnum,
for j = 1 : innum,
deriv(i,j)= deltaE/deltaW(i,j);
end;
end;
%Learning with momentum algorithm
gradE = -eta*deriv;
momenW = alpha*deltaW;
deltaW = gradE + momenW;
dem = dem + 1;
end;
.......
In the '.....' I will use the 'plot' command. Do you think it's suitable? please give me some advice.
I'm looking forward to your suggestion.
|