📄 p129_65kohonen1_network.m
字号:
% Kohonen network
angles=0:0.5*pi/99:0.5*pi;
P=[sin(angles);cos(angles)];
h1=figure;
x1=P;x1(2, :)=[ ];
x2=P;x2(1 ,:)=[ ];
plot(x1,x2,'.');
hold on
[R,Q]=size(P),S=20;
W0=randnr(S,R)*0.1;
x1=W0;x1(2, :)=[ ];
x2=W0;x2(1 ,:)=[ ];
plot(x1,x2,'-');
%plot(W0,'-');
pause
W=W0;
max_cycle=400; % 设置最大循环次数
disp_freq=100;
lr=0.3;
max_neighb=S-1;
% 训练网络、修正权值
h2=figure
for cycle=1:max_cycle
x=cycle/max_cycle;
LR=(1-x)*lr;
n=max(max_neighb*(1-x*4),1);
A=compet(W*P);
i=find(A==1);
n=max(max_neighb*(1-1/x),1);
% for q=1:Q
% NP=S;
%in=nbgrid1(i,NP,n);
%in
%pause
dW=learnk(W,P,i,LR);
W=W+dW;
end
end
%TF=[disp_freq max_cycle lr max_neighb];
%W=trainsm(W,P,TF);
x1=W;x1(2, :)=[ ];
x2=W;x2(1 ,:)=[ ];
plot(x1,x2,'.');
W0,W
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -