fmap2.m

来自「《面向MATLAB工具箱的神经网络理论与应用》一书中实例的所有源代码」· M 代码 · 共 35 行

M
35
字号
%例6.6,fmap2.m
%
clear
P=rands(2,2000)*0.5;
x=0:0.1:3.1416*2;
plot(sin(x),cos(x));                         %画圆
axis('equal')
hold on
plot(P(1,:),P(2,:),'.g','markersize',10);          %画输入点
hold off
disp('按任一键继续')
pause

net=newsom(minmax(P),[5,5]);              %创建科荷伦网络
W0=rands(25,2)*0.1;                      %随机产生权值         
figure(2)
plot(sin(x),cos(x));                 
axis('equal')
hold on
plotsom(W0')                            %作神经元权值图
hold off
disp('按任一键继续')
pause

net.trainParam.epochs=25;                 %最大训练次数
net.trainParam.show=5;                   %显示间隔次数   
net.iw{1,1}=W0;                        %赋权值
net = train(net,P);                        %训练网络          
figure(3)
plot(sin(x),cos(x),'--');
hold on
plotsom(net.iw{1,1},net.layers{1}.distances)
                                      %画权值点及其与相邻权值点的连线 
hold off

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?