example74_sanger.m

来自「是一个用MATLAB编的一个系统」· M 代码 · 共 52 行

M
52
字号
%%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 + =
减小字号Ctrl + -
显示快捷键?