📄 lvq-potoexample.txt
字号:
P = [-3 -2 -2 0 0 0 0 2 2 3 ; 0 1 -1 2 1 -1 -2 1 -1 0];
Tc = [ 1 1 1 2 2 2 2 1 1 1 ];
i=[4 5 6 7];
j=[1 2 3 8 9 10];
figure(1)
plotvec(P(:,i),Tc(:,i),'square');
hold on
plotvec(P(:,j),Tc(:,j),'+');
title('Input Vectors');
m=['P1 ';'P2 ';'P3 ';'P4 ';'P5 ';'P6 ';'P7 ';'P8 ';'P9 ';'P10'];
x=P(1,:)';
y=P(2,:)';
text(x+0.1,y+0.1,m);
axis([min(P(1,:))-1 max(P(1,:))+1 min(P(2,:))-1 max(P(2,:))+1]);
hold off
T = ind2vec(Tc);
targets = full(T)
net = newlvq(minmax(P),4,[0.6 0.4],0.1);
net.trainParam.epochs = 150;
net = train(net,P,T);
net.IW{1,1}
net.LW{2,1}
figure(2)
plotvec(P(:,i),Tc(:,i),'square');
plotvec(P(:,i),Tc(:,i),'square');
hold on
plotvec(P(:,j),Tc(:,j),'+');
title('Input Vectors');
m=['P1 ';'P2 ';'P3 ';'P4 ';'P5 ';'P6 ';'P7 ';'P8 ';'P9 ';'P10'];
x=P(1,:)';
y=P(2,:)';
text(x+0.1,y+0.1,m);
axis([min(P(1,:))-1 max(P(1,:))+1 min(P(2,:))-1 max(P(2,:))+1]);
plotvec(net.IW{1,1}',vec2ind(net.LW{2,1}),'o');
hold off
Y = sim(net,P);
Yc = vec2ind(Y)
pchk1 = [0; 0.5];
Y = sim(net,pchk1);
Yc1 = vec2ind(Y)
pchk2 = [1; 0];
Y = sim(net,pchk2);
Yc2 = vec2ind(Y)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -