Main Content

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

競合学習

競合層のニューロンは、入力ベクトルが発生する入力空間のさまざまな領域を表すことを学習します。

P は、ランダムに生成され、クラスター化されたテスト データ点の集合です。次に、データ点をプロットします。

競合ネットワークは、これらの点を自然なクラスに分類するために使用されます。

% Create inputs X.
bounds = [0 1; 0 1];   % Cluster centers to be in these bounds.
clusters = 8;          % This many clusters.
points = 10;           % Number of points in each cluster.
std_dev = 0.05;        % Standard deviation of each cluster.
x = nngenc(bounds,clusters,points,std_dev);

% Plot inputs X.
plot(x(1,:),x(2,:),'+r');
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 a line object which displays its values using only markers.

ここで COMPETLAYER は、ニューロンの数と学習率の 2 つの引数を取ります。

ネットワーク入力を構成 (通常は TRAIN によって自動的に実行) して初期の重みベクトルをプロットし、その分類試行を確認できます。

重みベクトル (o) が入力ベクトル (+) のクラスターの中心に発生するように学習を行います。

net = competlayer(8,.1);
net = configure(net,x);
w = net.IW{1};
plot(x(1,:),x(2,:),'+r');
hold on;
circles = plot(w(:,1),w(:,2),'ob');

Figure contains an axes object. The axes object contains 2 objects of type line. One or more of the lines displays its values using only markers

停止までの学習エポック数を設定し、この競合層に学習させます (数秒かかることがあります)。

更新された層の重みを同じグラフにプロットします。

net.trainParam.epochs = 7;
net = train(net,x);

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

w = net.IW{1};
delete(circles);
plot(w(:,1),w(:,2),'ob');

Figure contains an axes object. The axes object contains 2 objects of type line. One or more of the lines displays its values using only markers

これで、競合層を分類器として使用することができます。各ニューロンはそれぞれ別のカテゴリに対応します。ここでは入力ベクトル X1 を [0; 0.2] として定義します。

出力 Y は応答しているニューロンを示すため、入力の属するクラスが示されます。

x1 = [0; 0.2];
y = net(x1)
y = 8×1

     0
     1
     0
     0
     0
     0
     0
     0