⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 comp1.m

📁 MATLAB工具箱的神经网络理论与应用程序源代码
💻 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 + -