Main Content

2-입력 퍼셉트론을 사용한 분류

4개의 입력 벡터를 2개의 범주로 분류하도록 2-입력 하드 리밋 뉴런을 훈련시킵니다.

X의 열 벡터 4개는 각각 요소를 2개 가진 입력 벡터를 정의하고, 행 벡터 T는 벡터의 목표 범주를 정의합니다. PLOTPV를 사용하여 이러한 벡터를 플로팅할 수 있습니다.

X = [ -0.5 -0.5 +0.3 -0.1;  ...
      -0.5 +0.5 -0.5 +1.0];
T = [1 1 0 0];
plotpv(X,T);

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

퍼셉트론은 X의 4개 입력 벡터를 T로 정의되는 2개의 범주로 올바르게 분류해야 합니다. 퍼셉트론은 HARDLIM 뉴런을 갖습니다. 이 뉴런은 직선을 사용해서 입력 공간을 2개의 범주(0과 1)로 분리할 수 있습니다.

다음은 PERCEPTRON이 하나의 뉴런을 가지는 새 신경망을 만듭니다. 그런 다음 신경망이 데이터에 맞춰 구성되어 초기 가중치 및 편향 값을 살펴볼 수 있습니다. (구성 단계는 ADAPT 또는 TRAIN에 의해 자동으로 수행되므로 일반적으로 건너뛰어도 됩니다.)

net = perceptron;
net = configure(net,X,T);

입력 벡터는 뉴런이 최초 분류를 시도할 때 다시 플로팅됩니다.

초기 가중치가 0으로 설정되어 있으므로 모든 입력값이 동일한 출력값을 생성하며 분류 선이 플롯에 나타나지도 않습니다. 걱정하지 마십시오. 신경망을 훈련시키면 됩니다.

plotpv(X,T);
plotpc(net.IW{1},net.b{1});

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

입력 데이터와 목표 데이터가 순차 데이터(각 열이 하나의 시간 스텝을 나타내는 셀형 배열)로 변환되고 세 번 복사되어 시계열 XX와 TT를 형성합니다.

ADAPT는 시계열의 각 시간 스텝에 대해 신경망을 업데이트하고, 더 나은 분류기로 동작하는 새 network 객체를 반환합니다.

XX = repmat(con2seq(X),1,3);
TT = repmat(con2seq(T),1,3);
net = adapt(net,XX,TT);
plotpc(net.IW{1},net.b{1});

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

이제 [0.7; 1.2]와 같은 다른 입력 벡터를 분류하기 위해 SIM이 사용됩니다. 이 새 점을 원본 훈련 세트와 함께 플로팅하면 신경망의 성능을 볼 수 있습니다. 훈련 세트에서 새 점을 구분하려면 빨간색으로 색칠하십시오.

x = [0.7; 1.2];
y = net(x);
plotpv(x,y);
point = findobj(gca,'type','line');
point.Color = 'red';

Figure contains an axes object. The axes object with title Vectors to be Classified, xlabel P(1), ylabel P(2) contains a line object which displays its values using only markers.

직전 플롯이 지워지지 않도록 "hold"를 켜고, 훈련 세트와 분류 선을 플로팅합니다.

퍼셉트론이 새 점(빨간색)을 범주 "1"(+로 표시)이 아닌 범주 "0"(원으로 표시)으로 올바르게 분류했습니다.

hold on;
plotpv(X,T);
plotpc(net.IW{1},net.b{1});
hold off;

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