Main Content

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

学習ベクトル量子化

特定のターゲットに応じて入力ベクトルを分類するように、LVQ ネットワークの学習を行います。

X を 10 個の 2 要素標本の入力ベクトル、C をこれらのベクトルが分類されるクラスとします。これらのクラスは IND2VEC でベクトルに変換して、ターゲット T として使用します。

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);

次に、データ点をプロットします。赤 = クラス 1、シアン = クラス 2 です。LVQ ネットワークは、隠れニューロンのあるベクトルのクラスターを表し、出力ニューロンのあるクラスターをグループ化して目的のクラスを形成します。

colormap(hsv);
plotvec(x,c)
title('Input Vectors');
xlabel('x(1)');
ylabel('x(2)');

Figure contains an axes object. The axes object with title Input Vectors, xlabel x(1), ylabel x(2) contains 10 objects of type line. One or more of the lines displays its values using only markers

ここで、LVQNET によって、4 個の隠れニューロンがあり、学習率が 0.1 の LVQ 層が作成されます。次に、入力 X およびターゲット T に対してネットワークが構成されます (通常、構成は TRAIN によって自動的に行われるため、この手順は不要です)。

net = lvqnet(4,0.1);
net = configure(net,x,t);

競合ニューロンの重みベクトルを以下のようにプロットします。

hold on
w1 = net.IW{1};
plot(w1(1,1),w1(1,2),'ow')
title('Input/Weight Vectors');
xlabel('x(1), w(1)');
ylabel('x(2), w(2)');

Figure contains an axes object. The axes object with title Input/Weight Vectors, xlabel x(1), w(1), ylabel x(2), w(2) contains 11 objects of type line. One or more of the lines displays its values using only markers

ネットワークの学習は、まず既定の数のエポックをオーバーライドした後に行います。完了したら、入力ベクトル '+' および競合ニューロンの重みベクトル 'o' を再プロットします。赤 = クラス 1、シアン = クラス 2 です。

net.trainParam.epochs=150;
net=train(net,x,t);

Figure Neural Network Training (27-Jul-2023 15:32:12) contains an object of type uigridlayout.

cla;
plotvec(x,c);
hold on;
plotvec(net.IW{1}',vec2ind(net.LW{2}),'o');

Figure contains an axes object. The axes object with title Input/Weight Vectors, xlabel x(1), w(1), ylabel x(2), w(2) contains 14 objects of type line. One or more of the lines displays its values using only markers

ここで、LVQ ネットワークを分類器として使用します。各ニューロンは異なるカテゴリに対応します。入力ベクトル [0.2; 1] を提示します。赤 = クラス 1、シアン = クラス 2 です。

x1 = [0.2; 1];
y1 = vec2ind(net(x1))
y1 = 2