example8_2.m
来自「matlab神经网络工具箱分析设计」· M 代码 · 共 24 行
M
24 行
%随机生成1000个二维向量,作为样本,并绘出其分布
P = rands(2,1000);
plot(P(1,:),P(2,:),'+r')
title('初始随机样本点分布');
xlabel('P(1)');
ylabel('P(2)');
%建立网络,得到初始权值
net=newsom([0 1; 0 1],[5 6]);
w1_init=net.iw{1,1}
%绘出初始权值分布图
figure;
plotsom(w1_init,net.layers{1}.distances)
%分别对不同的步长,训练网络,绘出相应的权值分布图
for i=10:30:100
net.trainParam.epochs=i;
net=train(net,P);
figure;
plotsom(net.iw{1,1},net.layers{1}.distances)
end
%对于训练好的网络,选择特定的输入向量,得到网络的输出结果
p=[0.5;0.3];
a=0;
a = sim(net,p)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?