?? example76.m
字號:
%%example76
%%training samples
in=10;
num=in;
b0(:,1)=reshape(double(rgb2gray(img1)),32*32,1);
b0(:,2)=reshape(double(rgb2gray(img2)),32*32,1);
b0(:,3)=reshape(double(rgb2gray(img3)),32*32,1);
b0(:,4)=reshape(double(rgb2gray(img4)),32*32,1);
b0(:,5)=reshape(double(rgb2gray(img5)),32*32,1);
b0(:,6)=reshape(double(rgb2gray(img6)),32*32,1);
b0(:,7)=reshape(double(rgb2gray(img7)),32*32,1);
b0(:,8)=reshape(double(rgb2gray(img8)),32*32,1);
b0(:,9)=reshape(double(rgb2gray(img9)),32*32,1);
b0(:,10)=reshape(double(rgb2gray(img10)),32*32,1);
%%initialize the parameters
cpts=8;
W=rand(cpts,32*32)*1e-3;
eta=str2num(rate);
maxsteps=str2num(epoch);
%from each column subtract the mean of the traing samples
b=sum(b0');
b=b'/10;
b0=b0-[b b b b b b b b b b ];
%%training the weight matrix with the GHA(Sanger) algorithm
for n=1:maxsteps
eta=eta;
y=zeros(cpts,10);
for r=1:cpts
y(r,:)=W(r,:)*b0 ;
b2=W'*y;
dW(r,:)=eta*y(r,:)*(b0'-b2');
W(r,:)=W(r,:)+dW(r,:);
end
E(n)=norm(b0-b2);
E0=E(n);
if (E0<1)
break, end;
step=n;
end
x=1:maxsteps;
E=E(x);
figure('name','網絡訓練過程圖示','numbertitle','off');
plot(x,E),title('Target Functioin');
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -