Model Representation I
์ ๊ฒฝ๋ง์ ์ฌ์ฉํด์ ์ด๋ป๊ฒ hypothesis function์ ํํํ ์ง ์๊ฐํด๋ณด๋๋ก ํ์. ๋งค์ฐ ๊ฐ๋จํ ์์ค์์, ๋ด๋ฐ์ ์ ๊ธฐ์ ์ ํธ๋ก ์ ๋ ฅ์ ๋ฐ์์ ์ถ๋ ฅ์ ์ฑ๋๋งํ๋ ๊ณ์ฐ ์ ๋์ผ๋ก ์๊ฐํ ์ ์๋ค. ๋ชจ๋ธ์ ๊ฐ๋ ์ผ๋ก ์๊ฐํด๋ณด๋ฉด ์ ๋ ฅ์ feature $x_1, \cdots x_n$์ด ๋๊ณ , ์ถ๋ ฅ์ hypothesis function์ ๊ฒฐ๊ณผ๊ฐ ๋๋ค. ๋ชจ๋ธ์์ $x_0$ ์ ๋ ฅ ๋ ธ๋๋ bias unit์ผ๋ก ๋ถ๋ฆฌ๊ธฐ๋ ํ๋๋ฐ, ์ด ๋ ธ๋๋ ํญ์ 1์ ๊ฐ์ ๊ฐ์ง๋ค. ์ ๊ฒฝ๋ง์์ ๋ถ๋ฅ์ฒ๋ผ ๋๊ฐ์ logistic function์ด๊ณ , sigmoid ํ์ฑํ ํจ์๋ผ๊ณ ๋ ๋ถ๋ฆฌ๋ $\frac {1}{1+e^{-\theta^{T}x}}$์ ์ฌ์ฉํ๋ค. ์ด ์ํฉ์์ ์ธํ ํ๋ผ๋ฏธํฐ๋ ๊ฐ์ค์น๋ผ๊ณ ๋ ๋ถ๋ฆฐ๋ค.
์๊ฐ์ ์ผ๋ก ๊ฐ๋จํ๊ฒ ํํํ๋ฉด ๋ค์๊ณผ ๊ฐ๋ค.
'์ ๋ ฅ ๋ ์ด์ด'๋ผ๊ณ ๋ ์๋ ค์ ธ ์๋, ์ ๋ ฅ ๋ ธ๋$($layer 1$)$๋ ๋ค๋ฅธ ๋ ธ๋$($layer 2$)$๋ก ํฅํ๊ฒ ๋๋ค. ์ด ๋ค๋ฅธ ๋ ธ๋๋ hypothesis function์ ์ต์ข ์ถ๋ ฅ์ ์ถ๋ ฅํ๋๋ฐ, '์ถ๋ ฅ ๋ ์ด์ด'๋ผ๊ณ ๋ถ๋ฆฐ๋ค. ์ด ๋ ๋ ์ด์ด ์ค๊ฐ์ ๋ค๋ฅธ ๋ ์ด์ด๋ค๋ ์กด์ฌํ๋๋ฐ, ์ด๋ค์ 'hidden layer'๋ผ๊ณ ๋ถ๋ฅธ๋ค. ์ด ์์์์๋, ์ด ์ค๊ฐ ํน์ 'hidden' ๋ ์ด์ด ๋ ธ๋ $a_{0}^{2} \cdots a_{n}^{2}$๋ก ๋ผ๋ฒจ๋งํ๊ณ 'activation unit'์ด๋ผ๊ณ ๋ถ๋ฅธ๋ค.
๋ง์ฝ ํ๋์ hidden layer๋ฅผ ๊ฐ์ง๊ณ ์๋ค๋ฉด ๋ค์๊ณผ ๊ฐ์ ํํ๋ฅผ ๊ฐ์ง๊ฒ ๋๋ค.
๊ฐ 'activation' ๋ ธ๋๋ค์ ๊ฐ์ ๋ค์๊ณผ ๊ฐ์ด ์ป๊ฒ ๋๋ค.
activation node๋ $3 \times 4$ ํฌ๊ธฐ์ ํ๋ ฌ์ ์ด์ฉํด์ ๊ณ์ฐ๋๋ค. ํ๋ผ๋ฏธํฐ์ ๊ฐ ํ์ ์ ๋ ฅ์ ์ ์ฉํด์ ํ๋์ activation node์ ๋ํ ๊ฐ์ ์ป๋๋ค. hypothesis ์ถ๋ ฅ์ ๋ ธ๋์ ๋ ๋ฒ์งธ ๋ ์ด์ด์ ๋ํ ๊ฐ์ค์น๋ฅผ ํฌํจํ๋ ๋ ๋ค๋ฅธ ๋งค๊ฐ๋ณ์ ํ๋ ฌ $\theta^{2}$๋ก ๊ณฑํด์ง activation node ๊ฐ์ ํฉ์ ์ ์ฉ๋ logistic ํจ์์ด๋ค.
๊ฐ ๋ ์ด์ด๋ ๊ฐ์์ ๊ฐ์ค์น ํ๋ ฌ์ธ $\theta^{(j)}$์ ๊ฐ๋๋ค. ์ด ๊ฐ์ค์น ํ๋ ฌ์ ์ฐจ์์ ๋ค์๊ณผ ๊ฐ์ด ๊ฒฐ์ ๋๋ค.
layer j์์ ๋คํธ์ํฌ๊ฐ $s_j$ ์ ๋๊ณผ layer j+1์์ $s_{j+1}$ ์ ๋์ ๊ฐ์ง๋ฉด $\theta^{j}$์ ์ฐจ์์ $s_{j+1} \times (s_{j} + 1)$์ ๊ฐ์ง๋ค.
1์ด ๋ํด์ง ์ด์ ๋ $\theta^{(j)}$์ bias node์ธ $x_{0}$๊ณผ $\theta_{0}^{(j)}$์ ์ถ๊ฐ๋ก ์จ ๊ฒ์ด๋ค. ์ฆ, ์ถ๋ ฅ ๋ ธ๋์๋ bias node๋ฅผ ํฌํจ๋์ง ์์ง๋ง, ์ ๋ ฅ ๋ ธ๋์๋ ํฌํจ๋๋ค. ๋ค์์ ๊ทธ๋ฆผ์ model ํํ์ ์์ฝํ๊ณ ์๋ค.
์๋ฅผ ๋ค์ด, layer 1์ด 2๊ฐ์ ์ ๋ ฅ ๋ ธ๋๋ฅผ ๊ฐ๊ณ , layer 2๊ฐ 4๊ฐ์ activation node๋ฅผ ๊ฐ์ง๋ค๊ณ ํด๋ณด์. $\theta^{(1)}$์ ์ฐจ์์ $4 \times 3$์ด ๋๋ค. ์ฌ๊ธฐ์ $s_j = 2$์ด๊ณ $s_{j+1}=4$์ด๋ค. ๊ทธ๋์ $s_{j+1} \times (s_j + 1) = 4 \times 3$์ด ๋๋ค.
Model Representation II
๋ค์์ ์ ๊ฒฝ๋ง์ ์์์ด๋ค.
์ด ์น์ ์์๋ ์ ํจ์์ ๋ฒกํฐํ๋ ๊ตฌํ์ ํด๋ณด๋๋ก ํ๊ฒ ๋ค. $g$ ํจ์์ ์์ ์๋ ํ๋ผ๋ฏธํฐ๋ฅผ ํฌํจํ๋ ์๋ก์ด ๋ณ์ $z_{k}^{(j)}$์ ์ ์ํ๋๋ก ํ๊ฒ ๋ค. ์ด์ ์ ์์์์ ๋ชจ๋ ํ๋ผ๋ฏธํฐ๋ฅผ ๋ณ์ $z$๋ก ๋ฐ๊พธ๋ฉด ๋ค์์ ์ป๊ฒ ๋๋ค.
๋ค๋ฅธ ๋ง๋ก ํ๋ฉด, layer $j=2$์ ๋ ธ๋ $k$์ ๋ํด ๋ณ์ $z$๋ ๋ค์๊ณผ ๊ฐ๋ค.
$x$์ $z^{j}$์ ๋ฒกํฐ ํํ์ ๋ค์๊ณผ ๊ฐ๋ค.
$x = a^{(1)}$์ผ๋ก ์ค์ ํ๋ฉด, ๋ฐฉ์ ์์ ๋ค์๊ณผ ๊ฐ์ด ๋ฐ๊ฟ ์ธ ์ ์๋ค.
ํ๋ ฌ $\theta^{(j-1)}$๊ณผ ์ฐจ์ $s_j \times (n+1)$$($์ฌ๊ธฐ์ $s_j$๋ activation node์ ์$)$์ ๋์ด $(n+1)$์ธ ๋ฒกํฐ $a^{(j-1)}$๊ณผ ๊ณฑํ๋ค. ์ด๊ฒ์ ๋์ด๊ฐ $s_j$์ธ ๋ฒกํฐ $z^{(j)}$๋ฅผ ์ค๋ค. ์ด์ layer $j$์ ๋ํ activation node์ ๋ฒกํฐ๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ์ป์ ์ ์๋ค.
$a^{(j)} = g(z^{(j)})$
์ฌ๊ธฐ์ ํจ์ $g$๋ ๋ฒกํฐ $z^{(j)}$์ element-wiseํ๊ฒ ์ ์ฉ๋ ์ ์๋ค. $a^{(j)}$๋ฅผ ๊ณ์ฐํ ๋ค์์ layer $j$์ bias unit์ ๋ํ ์ ์๋ค. ์ด๊ฒ์ ์์ $a_{0}^{(j)}$๊ฐ ๋๊ณ , 1๊ณผ ๊ฐ์ ๊ฐ์ ๊ฐ์ง๊ฒ ๋๋ค. ์ต์ข hypothesis๋ฅผ ๊ฒ์ฌํ๊ธฐ ์ํด, ๋ค๋ฅธ $z$๋ฒกํฐ๋ถํฐ ๊ณ์ฐํด์ผ ํ๋ค.
$z^{(j+1)} = \theta^{(j)}a^{(j)}$
๋ฐฉ๊ธ ์ป์ ๋ชจ๋ activation node์ ๊ฐ์ $\theta^{(j-1)}$ ๋ค์ ์ธํ ํ๋ ฌ์ ๊ณฑํ์ฌ ์ต์ข ๋ฒกํฐ $z$๋ฅผ ์ป๋๋ค. ์ด ๋ง์ง๋ง ์ธํ ํ๋ ฌ $\theta^{(j)}$๋ ์ค์ง ํ๋์ ํ์ ๊ฐ์ง ๊ฒ์ด๊ณ , ์ด๋ ํ๋์ ์ด $a^{(j)}$์ ์ํด ๊ณฑํด์ ธ์ ๊ฒฐ๊ณผ์ ์ผ๋ก ํ๋์ ์ซ์๋ฅผ ๊ฐ๊ฒ ๋๋ค. ์ต์ข ์ ์ธ ๊ฒฐ๊ณผ๋ ๋ค์๊ณผ ๊ฐ๋ค.
$h_{\theta}(x) = a^{(j+1)} = g(z^{(j+1)})$
layer $j$์ layer $j+1$ ์ฌ์ด์ ์ด ๋ง์ง๋ง ๋จ๊ณ์์ logistic regression์์ ํ๋ ๊ฒ๊ณผ ์ ํํ ๊ฐ์ ์ผ์ ํ๊ณ ์๋ค. ์ด๋ฌํ ๋ชจ๋ ์ค๊ฐ ๋ ์ด์ด๋ค์ ์ ๊ฒฝ๋ง์ ์ถ๊ฐํ๋ ๊ฒ์ ๋ ์ธ๋ จ๋๊ณ ํฅ๋ฏธ๋ก์ด ์ถ๋ ฅ์ ํ๊ณ , ๋ณต์กํ ๋น์ ํ hypothesis๋ฅผ ๊ฐ๋ฅํ๊ฒ ํด์ค๋ค.
'Lecture ๐งโ๐ซ > Coursera' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Machine Learning] Backpropagation in Practice (0) | 2023.03.27 |
---|---|
[Machine Learning] Cost Function & Backpropagation (0) | 2023.03.26 |
[Machine Learning] Solving the Problem of Overfitting (2) | 2023.03.20 |
[Machine Learning] Multiclass Classification (0) | 2023.03.15 |
[Machine Learning] Classification & Representation (0) | 2023.03.15 |