📄 lvqnet2.m
字号:
function LVQnet2()
%指定输入二维向量及其类别并将这些类别转化为学习向量量化网络使用的目标向量,且绘制这些向量
X=[-3 -2 -2 0 0 0 0 2 2 3;0 1 -1 2 1 -1 -2 1 -1 0];
C=[1 1 1 2 2 2 2 1 1 1];
T=ind2vec(C);plotvec(X,C);
T
net=newlvq(minmax(X),4,[0.6 0.4],0.1)
w=net.iw{1};
figure;
plotvec(X,C);hold on;
plot(w(1,1),w(1,2),'ow');
xlabel('X(1),w(1)');ylabel('X(2),w(2)');
hold off;
net.trainParam.epochs=150;
net.trainParam.show=Inf;
net=train(net,X,T);
figure;plotvec(X,C);hold on;
plotvec(net.iw{1},vec2ind(net.lw{2}),'o')
X1=[0.8;0.3];
y1=sim(net,X1)
y=vec2ind(y1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -