Main Content

학습 벡터 양자화

주어진 목표값에 따라 입력 벡터를 분류하도록 LVQ 신경망을 훈련시킵니다.

X가 2개 요소를 가진 표본 입력 벡터 10개이고 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

신경망을 훈련시키려면 먼저 디폴트 Epoch 횟수를 재정의한 다음 신경망을 훈련시키십시오. 훈련이 끝나면 입력 벡터 '+'와 경쟁 뉴런의 가중 벡터 'o'를 다시 플로팅합니다. 빨간색은 클래스 1이고 녹청색은 클래스 2입니다.

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

Figure Neural Network Training (25-Jan-2024 15:35:33) 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