📄 example74_sanger.m
字号:
%%example74_sanger
clc
%%training samples
X=[1 2 0 1
0 3 1 4
1 1 1 1];
Ex=[1 2 1]';
%input pattern vectors
X1=X-[Ex Ex Ex Ex];
%%initialize the parameters
cpts=2;
W=rand(cpts,3);
eta=str2num(rate);
maxsteps=str2num(epoch);
for n=1:maxsteps
eta=eta;
y=zeros(cpts,4);
for r=1:cpts
y(r,:)=W(r,:)*X1 ;
X2=W'*y;
dW(r,:)=eta*y(r,:)*(X1'-X2');
W(r,:)=W(r,:)+dW(r,:);
end
E(n)=norm(X1-X2);
E0=E(n);
if (E0<0)
break, end;
step=n;
end
%to look the primary components of the first sample
%and to see the target curve
%u=W*b0(:,1);\
y=W*X1;
x=1:cpts;
y=y(x,:);
x=1:maxsteps;
E=E(x);
figure;
plot(x,E),title('Target Functioin');
U=W';
N=n;
E0=E0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -