?? comp1.m
字號:
%例6.4 , comp1.m
%
clear
P=[0.7071 0.6402 0.000 -0.1961 0.1961 -0.9285 -0.8762 -0.8192;
0.7071 0.7682 -1.000 -0.9806 -0.9806 0.3714 0.4819 0.5735];
S=4;
[R,Q]=size(P);
net=newc(minmax(P),S); %創建競爭網絡
net.iw{1,1}=randnr(S,2); %賦歸一化后的權值
w1=net.iw{1,1} %輸出權值
b1=w1';
x=0:0.1:3.1416*2;
plot(sin(x),cos(x)); %畫圓
axis('equal')
xlabel('P(1,q)..+ W(i,1)..o')
ylabel('P(2,q) W(i,2)')
hold on
plot(P(1,:),P(2,:),'r+') %畫輸入狀態點
plot(b1(1,:),b1(2,:),'o') %畫初始權值點
for i=1:Q
plot([P(1,i) 0],[P(2,i) 0]) %畫輸入點和原點的連線
end
hold off
disp('按任一鍵繼續 ')
pause
net.trainParam.epochs=320; %最大訓練次數
net.trainParam.show=100; %顯示間隔
lp.lr=0.05;
net=train(net,P); %訓練競爭網絡
w2=net.iw{1,1} %輸出訓練后的權值
b2=w2';
a=zeros(4,Q)+compet(net.iw{1,1}*P) %輸出訓練后的結果
x=0:0.1:3.1416*2;
figure(2)
plot(sin(x),cos(x));
axis('equal')
xlabel('P(1,q)..+ W(i,1)..o')
ylabel('P(2,q) W(i,2)')
hold on
plot(P(1,:),P(2,:),'r+')
plot(b2(1,:),b2(2,:),'o') %作訓練后的權值點
for i=1:Q
plot([P(1,i) 0],[P(2,i) 0])
end
hold off
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -