[인공지능개론] Neural Networks①
Neural Networks는 스스로 학습하는 인간의 뇌를 모방한 알고리즘이다. 시스템에는 입력과 출력이 존재한다. 인간의 뇌는 입력을 받아 이웃하는 뉴런으로부터의 가중치를 곱하여 합하는 weighted sum을 하여 전달하고 threshold와 비교하여 그보다 크면 1 아니면 0의 step function으로 전달하는 시스템과 닮아있다.
Dendrites : input for signals
Axon : output (signal transmission)
Synapse : determine weight of the signal from the axon (어느정도의 강도로 전달)
Soma : decide on whether to transmit signals to other neurons (전달 여부 결정)
기본 용어들을 정리해보자. threshold는 값을 활성화하기 위한 최소값이다. 즉, 신호를 전달할지 여부를 결정하기 위해 비교하는 최소한의 값을 갖는 기준치이다. weight는 linear classification으로 나타낸 가설모델 직선의 기울기이다. bias는 linear classification으로 나타낸 가설모델 직선의 y절편이다. neuron은 neural network의 가장 작은 요소이다. 앞서 언급한 것과 같이, $\sum (X\times weight + bias)>threshold$이면 activate 즉 신호를 전달하여 output = 1이 되는 반면, 그렇지 않다면 신호를 전달하지 않으면 output = 0 (or -1)이 된다.
Neural Networks
이는 보통 선형모델을 나타내며, 실제값과 예측값의 활성 함수 리턴값이 다를 경우 가중치를 업데이트하는 알고리즘 구조이다.
$a_i^{(j)}$는 j번째 layer에 있는 i번째 unit의 activation이다.
$\theta^{(j)}$는 j번째 layer와 j+1번째 layer 사이에 mapping되는 weights의 matrix이다. 여기서 j번째 layer의 units 수는 $s_j$, j+1번째 layer의 units 수는 $s_{j+1}$일 때 $\theta^{(j)}$의 차원은 $s_j\times s_{j+1}$이다.
Forward Propagation
$$a^{(1)}=x$$
$$z_1^{(2)}=\theta_{10}^{(1)}x_0+\theta_{11}^{(1)}x_1+\theta_{12}^{(1)}x_2+\theta_{13}^{(1)}x_3$$
$$ a_1^{(2)} = g(z_1^{(2)})$$
$$z_2^{(2)}=\theta_{20}^{(1)}x_0+\theta_{21}^{(1)}x_1+\theta_{22}^{(1)}x_2+\theta_{23}^{(1)}x_3$$
$$ a_2^{(2)} = g(z_2^{(2)})$$
$$z_3^{(2)}=\theta_{30}^{(1)}x_0+\theta_{31}^{(1)}x_1+\theta_{32}^{(1)}x_2+\theta_{33}^{(1)}x_3$$
$$ a_3^{(2)} = g(z_3^{(2)})$$
$$z^{(2)}=\theta^{(1)}x=\theta^{(1)}a^{(1)}$$
$$a^{(2)}=g(z^{(2)}) \rightarrow + a_0^{(2)}(=1)$$
$$z^{(3)}=\theta^{(2)}a^{(2)}=\theta_{10}^{(2)}x_0+\theta_{11}^{(2)}x_1+\theta_{12}^{(2)}x_2+\theta_{13}^{(2)}x_3$$
$$h_\theta(x)=a^{(3)}=g(z^{(3)})$$
여기서 주의할 점은 $a$는 단순히 가중합이 아닌 activation function을 거친 값이라는 것이다.
맨 처음 unit $a^{(1)}$은 activation function을 거치지 않으므로 $x$와 동일하다.
그 외의 나머지 $a$는 activation이다.
Single-Layer Perceptron: Hidden Layer가 없는 모델
Simple Example: AND, OR, NOT, NOT and NOT Problem $\leftarrow$ logistic function
AND Problem
: $y=x_1$ AND $x_2$
$(x_1,x_2 \in {0,1})$
OR Problem
: $y=x_1$ OR $x_2$
$(x_1,x_2 \in {0,1})$
NOT Problem
: $y=x_1$ NOT $x_2$
$(x_1,x_2 \in {0,1})$
NOT and NOT Problem
: $y=$(NOT $x_1$) AND (NOT $x_2$)
$(x_1,x_2 \in {0,1})$
Algorithm Structure
가중합 계산 : $net = \sum^N_{i=0}x_iw_i$
activation function 정의 : $f(net) = \left\{\begin{matrix}
1, net \geq threshold \\
0, net \leq threshold
\end{matrix}\right.$
learning rule 정의 : $w_i = w_i + \eta x_i(T-f(net))$
learning rule은 gradient descent와 매우 유사하다. $\triangledown x \approx x\times error$
Learning Rule Example
초기값을 기준으로 주어진 진리표의 값들을 대입하여 $net$을 구해서 0을 기준으로 작으면 $f(net)=0$, 크면 $f(net)=1$로 예측하여, 예측치와 실제 target 값을 비교한다. 같다면 유지하고 다르다면 learning rule에 의해 모든 parameter 값들을 update한다. update한 parameter를 기준으로 진리표의 모든 값들을 대입하여 실제 target 값과 같은지 비교한다. 여전히 다른 곳이 존재한다면 다시 learning rule을 적용하며 모든 data에 대한 실제 target 값과 예측치가 동일할 때까지 반복한다.
하지만 Single-Layer Perceptron은 linear model로 나타낼 수 있는 problem만을 해결할 수 있으며, XOR과 같은 nonlinear model로 나타내야 하는 problem은 해결하지 못한다. 이를 해결하기 위해서는 Multi-Layer Perceptron을 이용해야 한다.
[출처] 한양대학교 장준혁 교수님 인공지능개론 수업